+ def run(self, command, message=None, background=False, dry_run=False):
+ local_command = self.actual_command(command, dry_run=dry_run)
+ if dry_run:
+ utils.header("DRY RUN " + local_command)
+ return 0
+ else:
+ self.header(message)
+ return utils.system(local_command, background)
+
+ def run_in_buildname(self, command, background=False, dry_run=False):
+ if self.is_local():
+ return utils.system(command, background)
+ self.create_buildname_once(dry_run)
+ return self.run("cd {} ; {}".format(self.fullname(self.buildname), command),
+ background=background, dry_run=dry_run)
+
+ def fullname(self, dirname):
+ if self.root==None:
+ return dirname
+ else:
+ return os.path.join(self.root,dirname)
+
+ def mkdir(self, dirname=None, abs=False, dry_run=False):
+ if self.is_local():
+ if dirname:
+ return os.path.mkdir(dirname)
+ return 0
+ # ab. paths remain as-is
+ if not abs:
+ if dirname:
+ dirname = "{}/{}".format(self.buildname, dirname)
+ else:
+ dirname = self.buildname
+ dirname = self.fullname(dirname)
+ if dirname == '.':
+ return
+ return self.run("mkdir -p {}".format(dirname), dry_run=dry_run)
+
+ def rmdir(self, dirname=None, dry_run=False):
+ if self.is_local():
+ if dirname:
+ return shutil.rmtree(dirname)
+ return 0
+ if dirname:
+ dirname = "{}/{}".format(self.buildname, dirname)
+ else:
+ dirname = self.buildname
+ dirname = self.fullname(dirname)
+ return self.run("rm -rf {}".format(dirname), dry_run=dry_run)
+
+ def create_buildname_once(self, dry_run):
+ if self.is_local():
+ return
+ # create remote buildname on demand
+ try:
+ self.buildname_created
+ except:
+ self.mkdir(dry_run=dry_run)
+ self.buildname_created = True
+
+ def copy(self, local_file, recursive=False, dry_run=False):