def process_single_task(self, args): ''' do the work for a single task ''' self.args = self.check_for_branch_request(args) logging.basicConfig(format="%(message)s", stream=sys.stderr, level=logging.INFO) # force cleaning of our workspace on exit atexit.register(self.cleanup) scm2class = { 'git': 'Git', 'bzr': 'Bzr', 'hg': 'Hg', 'svn': 'Svn', 'tar': 'Tar', } # create objects for TarSCM.<scm> and TarSCM.helpers try: scm_class = getattr(TarSCM.scm, scm2class[args.scm]) except: msg = "Please specify valid --scm=... options" raise OptionsError(msg) # pylint: disable=W0707 # self.scm_object is need to unlock cache in cleanup # if exception occurs self.scm_object = scm_object = scm_class(args, self) tmode = bool(os.getenv('TAR_SCM_TESTMODE')) if not tmode and not scm_object.check_url(): sys.exit("--url does not match remote repository") try: scm_object.check_scm() except OSError: print("Please install '%s'" % scm_object.scm) sys.exit(1) scm_object.fetch_upstream() if args.filename: dstname = basename = args.filename else: dstname = basename = os.path.basename(scm_object.clone_dir) version = self.get_version() changesversion = version if version and args.filename_add_version \ and not sys.argv[0].endswith("/tar") \ and not sys.argv[0].endswith("/snapcraft") \ and not sys.argv[0].endswith("/appimage"): if isinstance(dstname, bytes): version = version.encode('UTF-8') dstname += '-' + version logging.debug("DST: %s", dstname) detected_changes = scm_object.detect_changes() if not args.use_obs_gbp: scm_object.prep_tree_for_archive(args.subdir, args.outdir, dstname=dstname) self.cleanup_dirs.append(scm_object.arch_dir) # For the GBP service there is no copy in arch_dir, so use clone_dir # which has the same content extract_src = scm_object.arch_dir if args.use_obs_scm: arch = TarSCM.archive.ObsCpio() elif args.use_obs_gbp: arch = TarSCM.archive.Gbp() extract_src = scm_object.clone_dir else: arch = TarSCM.archive.Tar() arch.extract_from_archive(extract_src, args.extract, args.outdir) arch.create_archive(scm_object, basename=basename, dstname=dstname, version=version, cli=args) if detected_changes: self._process_changes(args, version, changesversion, detected_changes) scm_object.finalize()
def process_single_task(self, args): ''' do the work for a single task ''' self.args = args logging.basicConfig(format="%(message)s", stream=sys.stderr, level=logging.INFO) if args.verbose: logging.getLogger().setLevel(logging.DEBUG) # force cleaning of our workspace on exit atexit.register(self.cleanup) scm2class = { 'git': 'Git', 'bzr': 'Bzr', 'hg': 'Hg', 'svn': 'Svn', 'tar': 'Tar', } # create objects for TarSCM.<scm> and TarSCM.helpers try: scm_class = getattr(TarSCM.scm, scm2class[args.scm]) except: raise OptionsError("Please specify valid --scm=... options") # self.scm_object is need to unlock cache in cleanup # if exception occurs self.scm_object = scm_object = scm_class(args, self) tmode = bool(os.getenv('TAR_SCM_TESTMODE')) if not tmode and not scm_object.check_url(): sys.exit("--url does not match remote repository") try: scm_object.check_scm() except OSError: print("Please install '%s'" % scm_object.scm) sys.exit(1) scm_object.fetch_upstream() if args.filename: dstname = basename = args.filename else: dstname = basename = os.path.basename(scm_object.clone_dir) version = self.get_version() changesversion = version if version and not sys.argv[0].endswith("/tar") \ and not sys.argv[0].endswith("/snapcraft") \ and not sys.argv[0].endswith("/appimage"): dstname += '-' + version logging.debug("DST: %s", dstname) detected_changes = scm_object.detect_changes() scm_object.prep_tree_for_archive(args.subdir, args.outdir, dstname=dstname) self.cleanup_dirs.append(scm_object.arch_dir) if args.use_obs_scm: arch = TarSCM.archive.ObsCpio() else: arch = TarSCM.archive.Tar() arch.extract_from_archive(scm_object.arch_dir, args.extract, args.outdir) arch.create_archive( scm_object, basename = basename, dstname = dstname, version = version, cli = args ) if detected_changes: self._process_changes(args, version, changesversion, detected_changes) scm_object.finalize()