本文整理汇总了Python中osclib.stagingapi.StagingAPI.prj_from_short方法的典型用法代码示例。如果您正苦于以下问题:Python StagingAPI.prj_from_short方法的具体用法?Python StagingAPI.prj_from_short怎么用?Python StagingAPI.prj_from_short使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osclib.stagingapi.StagingAPI
的用法示例。
在下文中一共展示了StagingAPI.prj_from_short方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_staging
# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import prj_from_short [as 别名]
#.........这里部分代码省略.........
strip=(opts.no_color or not bool(int(conf.config.get('staging.color', True)))))
# Allow colors to be changed.
for name in dir(Fore):
if not name.startswith('_'):
# .oscrc requires keys to be lower-case.
value = conf.config.get('staging.color.' + name.lower())
if value:
setattr(Fore, name, ansi.code_to_chars(value))
if opts.wipe_cache:
Cache.delete_all()
api = StagingAPI(opts.apiurl, opts.project)
needed = lock_needed(cmd, opts)
with OBSLock(opts.apiurl, opts.project, reason=cmd, needed=needed) as lock:
# call the respective command and parse args by need
if cmd == 'check':
if len(args) == 1:
CheckCommand(api).perform(None, opts.old)
else:
for prj in args[1:]:
CheckCommand(api).perform(prj, opts.old)
print()
elif cmd == 'check_duplicate_binaries':
CheckDuplicateBinariesCommand(api).perform(opts.save)
elif cmd == 'config':
projects = set()
key = value = None
stagings = api.get_staging_projects_short(None) + \
api.get_staging_projects()
for arg in args[1:]:
if arg in stagings:
projects.add(api.prj_from_short(arg))
elif key is None:
key = arg
elif value is None:
value = arg
else:
value += ' ' + arg
if not len(projects):
projects = api.get_staging_projects()
ConfigCommand(api).perform(projects, key, value, opts.append, opts.clear)
elif cmd == 'freeze':
for prj in args[1:]:
prj = api.prj_from_short(prj)
print(Fore.YELLOW + prj)
FreezeCommand(api).perform(prj, copy_bootstrap=opts.bootstrap)
elif cmd == 'frozenage':
projects = api.get_staging_projects_short() if len(args) == 1 else args[1:]
for prj in projects:
prj = api.prj_from_letter(prj)
print('{} last frozen {}{:.1f} days ago'.format(
Fore.YELLOW + prj + Fore.RESET,
Fore.GREEN if api.prj_frozen_enough(prj) else Fore.RED,
api.days_since_last_freeze(prj)))
elif cmd == 'acheck':
# Is it safe to accept? Meaning: /totest contains what it should and is not dirty
version_totest = api.get_binary_version(api.project, "openSUSE-release.rpm", repository="totest", arch="x86_64")
if version_totest:
version_openqa = api.pseudometa_file_load('version_totest')
totest_dirty = api.is_repo_dirty(api.project, 'totest')
print("version_openqa: %s / version_totest: %s / totest_dirty: %s\n" % (version_openqa, version_totest, totest_dirty))
else:
示例2: do_update_and_solve
# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import prj_from_short [as 别名]
def do_update_and_solve(self, subcmd, opts):
"""${cmd_name}: update and solve for given scope
${cmd_usage}
${cmd_option_list}
"""
if opts.staging:
match = re.match('(.*):Staging:(.*)', opts.staging)
opts.scope = ['staging:' + match.group(2)]
if opts.project:
raise ValueError('--staging and --project conflict')
opts.project = match.group(1)
elif not opts.project:
raise ValueError('project is required')
elif not opts.scope:
opts.scope = ['all']
apiurl = conf.config['apiurl']
Config(apiurl, opts.project)
target_config = conf.config[opts.project]
# Store target project as opts.project will contain subprojects.
target_project = opts.project
api = StagingAPI(apiurl, target_project)
main_repo = target_config['main-repo']
# used by product converter
# these needs to be kept in sync with OBS config
if apiurl.find('suse.de') > 0:
os.environ['OBS_NAME'] = 'build.suse.de'
if apiurl.find('opensuse.org') > 0:
os.environ['OBS_NAME'] = 'build.opensuse.org'
# special case for all
if opts.scope == ['all']:
opts.scope = target_config.get('pkglistgen-scopes', 'target').split(' ')
self.error_occured = False
def solve_project(project, scope):
try:
self.tool.reset()
self.tool.dry_run = self.options.dry
if self.tool.update_and_solve_target(api, target_project, target_config, main_repo,
project=project, scope=scope, force=opts.force,
no_checkout=opts.no_checkout,
only_release_packages=opts.only_release_packages,
stop_after_solve=opts.stop_after_solve):
self.error_occured = True
except Exception:
# Print exception, but continue to prevent problems effecting one
# project from killing the whole process. Downside being a common
# error will be duplicated for each project. Common exceptions could
# be excluded if a set list is determined, but that is likely not
# practical.
traceback.print_exc()
self.error_occured = True
for scope in opts.scope:
if scope.startswith('staging:'):
letter = re.match('staging:(.*)', scope).group(1)
solve_project(api.prj_from_short(letter), 'staging')
elif scope == 'target':
solve_project(target_project, scope)
elif scope == 'rings':
solve_project(api.rings[1], scope)
elif scope == 'staging':
letters = api.get_staging_projects_short()
for letter in letters:
solve_project(api.prj_from_short(letter), scope)
else:
raise ValueError('scope "{}" must be one of: {}'.format(scope, ', '.join(self.SCOPES)))
return self.error_occured
示例3: check
# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import prj_from_short [as 别名]
help='project to check (ex. openSUSE:Factory, openSUSE:Leap:15.1)')
parser.add_argument('-d', '--debug', action='store_true', default=False,
help='enable debug information')
parser.add_argument('-A', '--apiurl', metavar='URL', help='API URL')
args = parser.parse_args()
osc.conf.get_config(override_apiurl=args.apiurl)
osc.conf.config['debug'] = args.debug
apiurl = osc.conf.config['apiurl']
config = Config(apiurl, args.project)
api = StagingAPI(apiurl, args.project)
staging_report = InstallChecker(api, config)
if args.debug:
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.INFO)
result = True
if args.staging:
result = staging_report.staging(api.prj_from_short(args.staging), force=True)
else:
for staging in api.get_staging_projects():
if api.is_adi_project(staging):
result = staging_report.staging(staging) and result
if not result:
sys.exit( 1 )