def run(self): log_debug(2) if self.options.dest_file and self.options.topdir: die(6, "Error: conflicting options --dest-file and --topdir") if len(self.args) == 0: die(0, "No files supplied (use --help for help)") channel = self.options.channel if not channel: die(6, "Config channel not specified") r = self.repository if not r.config_channel_exists(channel): die(6, "Error: config channel %s does not exist" % channel) topdir = self.options.topdir revision = self.options.revision files_to_diff = [] files = map(utils.normalize_path, self.args) files_count = len(files) if files_count != 1 and revision is not None: die(8, "--revision can only be used with a single file") if self.options.dest_file: if files_count != 1: die(7, "--dest-file accepts a single file") files_to_diff.append((files[0], self.options.dest_file)) elif topdir: if not os.path.isdir(topdir): die(8, "--topdir specified, but `%s' not a directory" % topdir) #5/11/04 wregglej - 141790 remove trailing slash in topdir, if present. topdir = utils.rm_trailing_slash(topdir) for f in files: if not f.startswith(topdir): die( 8, "--topdir %s specified, but file `%s' doesn't comply" % (topdir, f)) if os.path.isdir(f) and not os.path.islink(f): die(8, "Cannot diff %s; it is a directory" % f) files_to_diff.append((f, f[len(topdir):])) else: for f in files: if os.path.isdir(f) and not os.path.islink(f): die(8, "Cannot diff %s; it is a directory" % f) files_to_diff.append((f, f)) for (local_file, remote_file) in files_to_diff: sys.stdout.write( self.diff_file(channel, remote_file, local_file, revision))
def run(self): log_debug(2) if self.options.dest_file and self.options.topdir: die(6, "Error: conflicting options --dest-file and --topdir") if len(self.args) == 0: die(0, "No files supplied (use --help for help)") channel = self.options.channel if not channel: die(6, "Config channel not specified") r = self.repository if not r.config_channel_exists(channel): die(6, "Error: config channel %s does not exist" % channel) topdir = self.options.topdir revision = self.options.revision files_to_diff = [] files = [utils.normalize_path(x) for x in self.args] files_count = len(files) if files_count != 1 and revision is not None: die(8, "--revision can only be used with a single file") if self.options.dest_file: if files_count != 1: die(7, "--dest-file accepts a single file") files_to_diff.append((files[0], self.options.dest_file)) elif topdir: if not os.path.isdir(topdir): die(8, "--topdir specified, but `%s' not a directory" % topdir) #5/11/04 wregglej - 141790 remove trailing slash in topdir, if present. topdir = utils.rm_trailing_slash(topdir) for f in files: if not f.startswith(topdir): die(8, "--topdir %s specified, but file `%s' doesn't comply" % (topdir, f)) if os.path.isdir(f) and not os.path.islink(f): die(8, "Cannot diff %s; it is a directory" % f) files_to_diff.append((f, f[len(topdir):])) else: for f in files: if os.path.isdir(f) and not os.path.islink(f): die(8, "Cannot diff %s; it is a directory" % f) files_to_diff.append((f, f)) for (local_file, remote_file) in files_to_diff: sys.stdout.write( self.diff_file(channel, remote_file, local_file, revision))
def run(self): log_debug(2) if self.options.dest_file and self.options.topdir: die(6, "Error: conflicting options --dest-file and --topdir") if len(self.args) == 0: die(0, "No files supplied (use --help for help)") channel = self.options.channel if not channel: die(6, "Config channel not specified") r = self.repository if not r.config_channel_exists(channel): die(6, "Error: config channel %s does not exist" % channel) files = map(utils.normalize_path, self.args) files_to_push = [] if self.options.dest_file: if len(files) != 1: die(7, "--dest-file accepts a single file") if not (self.options.dest_file[0] == os.sep): die(7, "--dest-file argument must begin with " + os.sep) files_to_push.append((files[0], self.options.dest_file)) elif self.options.topdir: if not os.path.isdir(self.options.topdir): die(8, "--topdir specified, but `%s' not a directory" % self.options.topdir) #5/11/05 wregglej - 141790 remove the trailing slash from topdir self.options.topdir = utils.rm_trailing_slash(self.options.topdir) for f in files: if not f.startswith(self.options.topdir): die(8, "--topdir %s specified, but file `%s' doesn't comply" % (self.options.topdir, f)) files_to_push.append((f, f[len(self.options.topdir):])) else: for f in files: #if a file is given w/o a full path, then use the abspath of the #file as name of the file to be uploaded into the channel if not (f[0] == os.sep): files_to_push.append((f, os.path.abspath(f))) else: files_to_push.append((f, f)) for (local_file, remote_file) in files_to_push: if not os.path.exists(local_file): if self.options.ignore_missing: files_to_push.remove((local_file,remote_file)) print "Local file %s does not exist. Ignoring file..." %(local_file) else: die(9, "No such file `%s'" % local_file) print "Pushing to channel %s:" % (channel, ) delim_start = self.options.delim_start delim_end = self.options.delim_end selinux_ctx = None if type(self.options.selinux_context) != None: selinux_ctx = self.options.selinux_context for (local_file, remote_file) in files_to_push: try: r.put_file(channel, remote_file, local_file, is_first_revision=self.is_first_revision, delim_start=delim_start, delim_end=delim_end, selinux_ctx=selinux_ctx) except cfg_exceptions.RepositoryFileExistsError, e: log_error("Error: %s is already in channel %s" % (remote_file, channel)) except cfg_exceptions.RepositoryFilePushError, e: log_error("Error pushing file: %s" % e)