1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-21 17:56:19 +02:00

Merge pull request #1169 from dirkmueller/handle_dot_expansion_in_more_commands

use Path.cwd() consistently
This commit is contained in:
Daniel Mach 2022-10-13 12:45:01 +02:00 committed by GitHub
commit 741180fc52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -210,18 +210,18 @@ class Osc(cmdln.Cmdln):
def get_api_url(self): def get_api_url(self):
try: try:
localdir = os.getcwd() localdir = Path.cwd()
except Exception as e: except Exception as e:
# check for Stale NFS file handle: '.' # check for Stale NFS file handle: '.'
try: try:
os.stat('.') os.stat('.')
except Exception as ee: except Exception as ee:
e = ee e = ee
print("os.getcwd() failed: ", e, file=sys.stderr) print("Path.cwd() failed: ", e, file=sys.stderr)
sys.exit(1) sys.exit(1)
if (is_package_dir(localdir) or is_project_dir(localdir)) and not self.options.apiurl: if (is_package_dir(localdir) or is_project_dir(localdir)) and not self.options.apiurl:
return store_read_apiurl(os.curdir) return store_read_apiurl(Path.cwd())
else: else:
return conf.config['apiurl'] return conf.config['apiurl']
@ -271,22 +271,22 @@ class Osc(cmdln.Cmdln):
if scm_url: if scm_url:
if package: if package:
Package.init_package(apiurl, project, package, os.curdir, scm_url=scm_url) Package.init_package(apiurl, project, package, Path.cwd(), scm_url=scm_url)
print('Initializing %s (Project: %s, Package: %s) as git repository' % (os.curdir, project, package)) print('Initializing %s (Project: %s, Package: %s) as git repository' % (Path.cwd(), project, package))
else: else:
Project.init_project(apiurl, os.curdir, project, conf.config['do_package_tracking'], Project.init_project(apiurl, Path.cwd(), project, conf.config['do_package_tracking'],
getPackageList=False, scm_url=scm_url) getPackageList=False, scm_url=scm_url)
print('Initializing %s (Project: %s) as scm repository' % (os.curdir, project)) print('Initializing %s (Project: %s) as scm repository' % (Path.cwd(), project))
return return
if not package: if not package:
Project.init_project(apiurl, os.curdir, project, conf.config['do_package_tracking'], Project.init_project(apiurl, Path.cwd(), project, conf.config['do_package_tracking'],
getPackageList=False) getPackageList=False)
print('Initializing %s (Project: %s)' % (os.curdir, project)) print('Initializing %s (Project: %s)' % (Path.cwd(), project))
else: else:
Package.init_package(apiurl, project, package, os.curdir) Package.init_package(apiurl, project, package, Path.cwd())
store_write_string(os.curdir, '_files', show_files_meta(apiurl, project, package) + b'\n') store_write_string(Path.cwd(), '_files', show_files_meta(apiurl, project, package) + b'\n')
print('Initializing %s (Project: %s, Package: %s)' % (os.curdir, project, package)) print('Initializing %s (Project: %s, Package: %s)' % (Path.cwd(), project, package))
@cmdln.alias('ls') @cmdln.alias('ls')
@cmdln.alias('ll') @cmdln.alias('ll')
@ -401,7 +401,7 @@ class Osc(cmdln.Cmdln):
# ls -b toplevel doesn't make sense, so use info from # ls -b toplevel doesn't make sense, so use info from
# current dir if available # current dir if available
if len(args) == 0: if len(args) == 0:
cwd = os.getcwd() cwd = Path.cwd()
if is_project_dir(cwd): if is_project_dir(cwd):
project = store_read_project(cwd) project = store_read_project(cwd)
elif is_package_dir(cwd): elif is_package_dir(cwd):
@ -517,7 +517,7 @@ class Osc(cmdln.Cmdln):
args = slash_split(args) args = slash_split(args)
apiurl = self.get_api_url() apiurl = self.get_api_url()
localdir = os.getcwd() localdir = Path.cwd()
project = package = None project = package = None
if not args: if not args:
if is_package_dir(localdir): if is_package_dir(localdir):
@ -558,7 +558,7 @@ class Osc(cmdln.Cmdln):
args = slash_split(args) args = slash_split(args)
apiurl = self.get_api_url() apiurl = self.get_api_url()
localdir = os.getcwd() localdir = Path.cwd()
channel = None channel = None
if not args: if not args:
if is_project_dir(localdir) or is_package_dir(localdir): if is_project_dir(localdir) or is_package_dir(localdir):
@ -601,7 +601,7 @@ class Osc(cmdln.Cmdln):
args = slash_split(args) args = slash_split(args)
apiurl = self.get_api_url() apiurl = self.get_api_url()
localdir = os.getcwd() localdir = Path.cwd()
channel = None channel = None
if not args: if not args:
if is_project_dir(localdir): if is_project_dir(localdir):
@ -646,7 +646,7 @@ class Osc(cmdln.Cmdln):
args = slash_split(args) args = slash_split(args)
apiurl = self.get_api_url() apiurl = self.get_api_url()
project_dir = localdir = os.getcwd() project_dir = localdir = Path.cwd()
patchinfo = 'patchinfo' patchinfo = 'patchinfo'
if len(args) == 0: if len(args) == 0:
if is_project_dir(localdir): if is_project_dir(localdir):
@ -719,8 +719,8 @@ class Osc(cmdln.Cmdln):
apiurl = self.get_api_url() apiurl = self.get_api_url()
if len(args) == 0: if len(args) == 0:
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
elif len(args) == 2: elif len(args) == 2:
project = self._process_project_name(args[0]) project = self._process_project_name(args[0])
package = args[1] package = args[1]
@ -770,13 +770,13 @@ class Osc(cmdln.Cmdln):
if len(args) == 4: if len(args) == 4:
devpkg = args[3] devpkg = args[3]
elif len(args) >= 1 and len(args) <= 2: elif len(args) >= 1 and len(args) <= 2:
project, package = store_read_project(os.curdir), store_read_package(os.curdir) project, package = store_read_project(Path.cwd()), store_read_package(Path.cwd())
devprj = self._process_project_name(args[0]) devprj = self._process_project_name(args[0])
if len(args) == 2: if len(args) == 2:
devpkg = args[1] devpkg = args[1]
else: else:
if opts.unset: if opts.unset:
project, package = store_read_project(os.curdir), store_read_package(os.curdir) project, package = store_read_project(Path.cwd()), store_read_package(Path.cwd())
else: else:
raise oscerr.WrongArgs('need at least DEVPRJ (and possibly DEVPKG)') raise oscerr.WrongArgs('need at least DEVPRJ (and possibly DEVPKG)')
@ -792,7 +792,7 @@ class Osc(cmdln.Cmdln):
args = slash_split(args) args = slash_split(args)
apiurl = self.get_api_url() apiurl = self.get_api_url()
localdir = os.getcwd() localdir = Path.cwd()
project = package = None project = package = None
if len(args) == 2: if len(args) == 2:
project = self._process_project_name(args[0]) project = self._process_project_name(args[0])
@ -996,17 +996,17 @@ class Osc(cmdln.Cmdln):
attributepath = [] attributepath = []
if cmd in ['prj', 'prjconf']: if cmd in ['prj', 'prjconf']:
if len(args) < 1: if len(args) < 1:
apiurl = store_read_apiurl(os.curdir) apiurl = store_read_apiurl(Path.cwd())
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
else: else:
project = self._process_project_name(args[0]) project = self._process_project_name(args[0])
elif cmd == 'pkg': elif cmd == 'pkg':
if len(args) < 2: if len(args) < 2:
apiurl = store_read_apiurl(os.curdir) apiurl = store_read_apiurl(Path.cwd())
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
if len(args) < 1: if len(args) < 1:
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
else: else:
package = args[0] package = args[0]
else: else:
@ -1307,15 +1307,15 @@ class Osc(cmdln.Cmdln):
if len(args) > 4: if len(args) > 4:
raise oscerr.WrongArgs('Too many arguments.') raise oscerr.WrongArgs('Too many arguments.')
if len(args) == 2 and is_project_dir(os.getcwd()): if len(args) == 2 and is_project_dir(Path.cwd()):
sys.exit('You can not specify a target package when submitting an entire project\n') sys.exit('You can not specify a target package when submitting an entire project\n')
apiurl = self.get_api_url() apiurl = self.get_api_url()
if len(args) < 2 and is_project_dir(os.getcwd()): if len(args) < 2 and is_project_dir(Path.cwd()):
if opts.diff: if opts.diff:
raise oscerr.WrongOptions('\'--diff\' is not supported in a project working copy') raise oscerr.WrongOptions('\'--diff\' is not supported in a project working copy')
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
sr_ids = [] sr_ids = []
@ -1401,7 +1401,7 @@ class Osc(cmdln.Cmdln):
elif len(args) <= 2: elif len(args) <= 2:
# try using the working copy at hand # try using the working copy at hand
p = Package(os.curdir) p = Package(Path.cwd())
src_project = p.prjname src_project = p.prjname
src_package = p.name src_package = p.name
if p.apiurl != apiurl: if p.apiurl != apiurl:
@ -1576,10 +1576,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
def _submit_request(self, args, opts, options_block): def _submit_request(self, args, opts, options_block):
actionxml = "" actionxml = ""
apiurl = self.get_api_url() apiurl = self.get_api_url()
if len(args) == 0 and is_project_dir(os.getcwd()): if len(args) == 0 and is_project_dir(Path.cwd()):
# submit requests for multiple packages are currently handled via multiple requests # submit requests for multiple packages are currently handled via multiple requests
# They could be also one request with multiple actions, but that avoids to accepts parts of it. # They could be also one request with multiple actions, but that avoids to accepts parts of it.
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
pi = [] pi = []
pac = [] pac = []
@ -1633,7 +1633,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
elif len(args) <= 2: elif len(args) <= 2:
# try using the working copy at hand # try using the working copy at hand
p = Package(os.curdir) p = Package(Path.cwd())
src_project = p.prjname src_project = p.prjname
src_package = p.name src_package = p.name
if len(args) == 0 and p.islink(): if len(args) == 0 and p.islink():
@ -1725,7 +1725,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
raise oscerr.WrongArgs('Too many arguments.') raise oscerr.WrongArgs('Too many arguments.')
if len(args) == 0 and is_package_dir('.') and find_default_project(): if len(args) == 0 and is_package_dir('.') and find_default_project():
wd = os.curdir wd = Path.cwd()
devel_project = store_read_project(wd) devel_project = store_read_project(wd)
devel_package = package = store_read_package(wd) devel_package = package = store_read_package(wd)
project = find_default_project(self.get_api_url(), package) project = find_default_project(self.get_api_url(), package)
@ -1998,9 +1998,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
project = self._process_project_name(args[0]) project = self._process_project_name(args[0])
package = args[1] package = args[1]
user = args[2] user = args[2]
elif len(args) < 2 and is_package_dir(os.curdir): elif len(args) < 2 and is_package_dir(Path.cwd()):
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
if len(args) == 0: if len(args) == 0:
user = conf.get_apiurl_usr(apiurl) user = conf.get_apiurl_usr(apiurl)
else: else:
@ -2075,11 +2075,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
elif len(args) == 2: elif len(args) == 2:
project = self._process_project_name(args[0]) project = self._process_project_name(args[0])
package = args[1] package = args[1]
elif is_project_dir(os.getcwd()): elif is_project_dir(Path.cwd()):
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
elif is_package_dir(os.getcwd()): elif is_package_dir(Path.cwd()):
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
else: else:
raise oscerr.WrongArgs('Please specify at least a project.') raise oscerr.WrongArgs('Please specify at least a project.')
@ -2124,7 +2124,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
osc changedevelrequest PROJECT PACKAGE DEVEL_PROJECT [DEVEL_PACKAGE] osc changedevelrequest PROJECT PACKAGE DEVEL_PROJECT [DEVEL_PACKAGE]
""" """
if len(args) == 0 and is_package_dir('.') and find_default_project(): if len(args) == 0 and is_package_dir('.') and find_default_project():
wd = os.curdir wd = Path.cwd()
devel_project = store_read_project(wd) devel_project = store_read_project(wd)
devel_package = package = store_read_package(wd) devel_package = package = store_read_package(wd)
project = find_default_project(self.get_api_url(), package) project = find_default_project(self.get_api_url(), package)
@ -2352,8 +2352,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
package = opts.package package = opts.package
elif not opts.mine and not opts.user and not opts.group: elif not opts.mine and not opts.user and not opts.group:
try: try:
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
except oscerr.NoWorkingCopy: except oscerr.NoWorkingCopy:
pass pass
@ -2744,8 +2744,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if opts.unset: if opts.unset:
rev = None rev = None
if len(args) == 0: if not args:
p = Package(os.curdir) p = Package(Path.cwd())
project = p.prjname project = p.prjname
package = p.name package = p.name
apiurl = p.apiurl apiurl = p.apiurl
@ -2787,7 +2787,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
apiurl = self.get_api_url() apiurl = self.get_api_url()
if len(args) == 0: if len(args) == 0:
wd = os.curdir wd = Path.cwd()
project = store_read_project(wd) project = store_read_project(wd)
package = store_read_package(wd) package = store_read_package(wd)
update_local_dir = True update_local_dir = True
@ -2822,8 +2822,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
args = slash_split(args) args = slash_split(args)
apiurl = self.get_api_url() apiurl = self.get_api_url()
if len(args) == 0: if len(args) == 0:
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
elif len(args) == 2: elif len(args) == 2:
project = self._process_project_name(args[0]) project = self._process_project_name(args[0])
package = args[1] package = args[1]
@ -3099,11 +3099,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
raise oscerr.WrongArgs('Too many arguments.') raise oscerr.WrongArgs('Too many arguments.')
if len(args) == 0: if len(args) == 0:
if is_package_dir(os.curdir): if is_package_dir(Path.cwd()):
source_project = store_read_project(os.curdir) source_project = store_read_project(Path.cwd())
source_package = store_read_package(os.curdir) source_package = store_read_package(Path.cwd())
elif is_project_dir(os.curdir): elif is_project_dir(Path.cwd()):
source_project = store_read_project(os.curdir) source_project = store_read_project(Path.cwd())
else: else:
raise oscerr.WrongArgs('Too few arguments.') raise oscerr.WrongArgs('Too few arguments.')
if len(args) > 0: if len(args) > 0:
@ -3171,8 +3171,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if len(args) > 1: if len(args) > 1:
raise oscerr.WrongArgs('Too many arguments.') raise oscerr.WrongArgs('Too many arguments.')
if len(args) == 0 and is_project_dir(os.curdir): if len(args) == 0 and is_project_dir(Path.cwd()):
source_project = store_read_project(os.curdir) source_project = store_read_project(Path.cwd())
elif len(args) == 0: elif len(args) == 0:
raise oscerr.WrongArgs('Too few arguments.') raise oscerr.WrongArgs('Too few arguments.')
if len(args) > 0: if len(args) > 0:
@ -3309,18 +3309,18 @@ Please submit there instead, or use --nodevelproject to force direct submission.
source_project = target_project = release_project = opt_sourceupdate = None source_project = target_project = release_project = opt_sourceupdate = None
source_packages = [] source_packages = []
if len(args) == 0 and (is_project_dir(os.curdir) or is_package_dir(os.curdir)): if len(args) == 0 and (is_project_dir(Path.cwd()) or is_package_dir(Path.cwd())):
source_project = store_read_project(os.curdir) source_project = store_read_project(Path.cwd())
if is_package_dir(os.curdir): if is_package_dir(Path.cwd()):
source_packages = [store_read_package(os.curdir)] source_packages = [store_read_package(Path.cwd())]
elif len(args) == 0: elif len(args) == 0:
raise oscerr.WrongArgs('Too few arguments.') raise oscerr.WrongArgs('Too few arguments.')
if len(args) > 0: if len(args) > 0:
if len(args) == 1 and args[0] == '.': if len(args) == 1 and args[0] == '.':
if is_package_dir(os.curdir): if is_package_dir(Path.cwd()):
source_project = store_read_project(os.curdir) source_project = store_read_project(Path.cwd())
source_packages = [store_read_package(os.curdir)] source_packages = [store_read_package(Path.cwd())]
p = Package(os.curdir) p = Package(Path.cwd())
release_project = p.linkinfo.project release_project = p.linkinfo.project
else: else:
raise oscerr.WrongArgs('No package directory') raise oscerr.WrongArgs('No package directory')
@ -4132,14 +4132,14 @@ Please submit there instead, or use --nodevelproject to force direct submission.
raise oscerr.WrongArgs('Too many arguments.') raise oscerr.WrongArgs('Too many arguments.')
if len(args) == 0: if len(args) == 0:
if not is_package_dir(os.getcwd()): if not is_package_dir(Path.cwd()):
raise oscerr.WrongArgs('Current directory is not a checked out package. Please specify a project and a package.') raise oscerr.WrongArgs('Current directory is not a checked out package. Please specify a project and a package.')
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
elif len(args) == 1: elif len(args) == 1:
if not is_project_dir(os.getcwd()): if not is_project_dir(Path.cwd()):
raise oscerr.WrongArgs('Current directory is not a checked out project. Please specify a project and a package.') raise oscerr.WrongArgs('Current directory is not a checked out project. Please specify a project and a package.')
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
package = args[0] package = args[0]
elif len(args) == 2: elif len(args) == 2:
project = self._process_project_name(args[0]) project = self._process_project_name(args[0])
@ -4266,7 +4266,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
raise oscerr.WrongArgs('Too many arguments.') raise oscerr.WrongArgs('Too many arguments.')
if len(args) == 0: if len(args) == 0:
if is_project_dir(os.curdir): if is_project_dir(Path.cwd()):
newprj = Project('.', getPackageList=False).name newprj = Project('.', getPackageList=False).name
oldprj = self._get_branch_parent(newprj) oldprj = self._get_branch_parent(newprj)
if oldprj is None: if oldprj is None:
@ -4502,9 +4502,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
except: except:
pass pass
if len(args) == 1 and is_project_dir(os.curdir): if len(args) == 1 and is_project_dir(Path.cwd()):
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
project_dir = os.curdir project_dir = Path.cwd()
package = args[0] package = args[0]
if opts.deleted and package: if opts.deleted and package:
@ -5287,7 +5287,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if len(args) > 2: if len(args) > 2:
raise oscerr.WrongArgs('Too many arguments (required none, one, or two)') raise oscerr.WrongArgs('Too many arguments (required none, one, or two)')
project = package = None project = package = None
wd = os.curdir wd = Path.cwd()
if is_project_dir(wd): if is_project_dir(wd):
project = store_read_project(wd) project = store_read_project(wd)
elif is_package_dir(wd): elif is_package_dir(wd):
@ -5385,7 +5385,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
else: else:
raise oscerr.WrongArgs('Wrong number of arguments.') raise oscerr.WrongArgs('Wrong number of arguments.')
else: else:
wd = os.curdir wd = Path.cwd()
project = store_read_project(wd) project = store_read_project(wd)
if opts.xml: if opts.xml:
@ -5468,8 +5468,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if len(args) == 1 and args[0].startswith('http'): if len(args) == 1 and args[0].startswith('http'):
apiurl, project, package, repository, arch = parse_buildlogurl(args[0]) apiurl, project, package, repository, arch = parse_buildlogurl(args[0])
else: else:
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
if len(args) == 1: if len(args) == 1:
repository, arch = self._find_last_repo_arch(args[0], fatal=False) repository, arch = self._find_last_repo_arch(args[0], fatal=False)
if repository is None: if repository is None:
@ -5511,7 +5511,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print_buildlog(apiurl, quote_plus(project), quote_plus(package), quote_plus(repository), quote_plus(arch), offset, strip_time, opts.last, opts.lastsucceeded) print_buildlog(apiurl, quote_plus(project), quote_plus(package), quote_plus(repository), quote_plus(arch), offset, strip_time, opts.last, opts.lastsucceeded)
def print_repos(self, repos_only=False, exc_class=oscerr.WrongArgs, exc_msg='Missing arguments', project=None): def print_repos(self, repos_only=False, exc_class=oscerr.WrongArgs, exc_msg='Missing arguments', project=None):
wd = os.curdir wd = Path.cwd()
doprint = False doprint = False
if is_package_dir(wd): if is_package_dir(wd):
msg = 'Valid arguments for this package are:' msg = 'Valid arguments for this package are:'
@ -5605,7 +5605,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print_buildlog(apiurl, quote_plus(project), quote_plus(package), quote_plus(repository), quote_plus(arch), offset, strip_time, opts.last, opts.lastsucceeded) print_buildlog(apiurl, quote_plus(project), quote_plus(package), quote_plus(repository), quote_plus(arch), offset, strip_time, opts.last, opts.lastsucceeded)
def _find_last_repo_arch(self, repo=None, fatal=True): def _find_last_repo_arch(self, repo=None, fatal=True):
files = glob.glob(os.path.join(os.getcwd(), store, "_buildinfo-*")) files = glob.glob(os.path.join(Path.cwd(), store, "_buildinfo-*"))
if repo is not None: if repo is not None:
files = [f for f in files files = [f for f in files
if os.path.basename(f).replace('_buildinfo-', '').startswith(repo + '-')] if os.path.basename(f).replace('_buildinfo-', '').startswith(repo + '-')]
@ -5654,7 +5654,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
repo = args[0] repo = args[0]
arch = args[1] arch = args[1]
else: else:
if is_package_dir(os.curdir): if is_package_dir(Path.cwd()):
self.print_repos() self.print_repos()
raise oscerr.WrongArgs('Wrong number of arguments.') raise oscerr.WrongArgs('Wrong number of arguments.')
@ -5700,7 +5700,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
osc triggerreason REPOSITORY ARCH osc triggerreason REPOSITORY ARCH
osc triggerreason PROJECT PACKAGE[:FLAVOR] REPOSITORY ARCH osc triggerreason PROJECT PACKAGE[:FLAVOR] REPOSITORY ARCH
""" """
wd = os.curdir wd = Path.cwd()
args = slash_split(args) args = slash_split(args)
project = package = repository = arch = None project = package = repository = arch = None
@ -5791,7 +5791,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
self._dependson(True, *args) self._dependson(True, *args)
def _dependson(self, reverse, *args): def _dependson(self, reverse, *args):
wd = os.curdir wd = Path.cwd()
args = slash_split(args) args = slash_split(args)
project = packages = repository = arch = None project = packages = repository = arch = None
@ -5874,7 +5874,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
osc buildinfo [OPTS] PROJECT PACKAGE[:FLAVOR] REPOSITORY ARCH [BUILD_DESCR] osc buildinfo [OPTS] PROJECT PACKAGE[:FLAVOR] REPOSITORY ARCH [BUILD_DESCR]
""" """
wd = os.curdir wd = Path.cwd()
args = slash_split(args) args = slash_split(args)
project = package = repository = arch = build_descr = None project = package = repository = arch = build_descr = None
@ -5942,7 +5942,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
osc buildconfig PROJECT REPOSITORY osc buildconfig PROJECT REPOSITORY
""" """
wd = os.curdir wd = Path.cwd()
args = slash_split(args) args = slash_split(args)
if len(args) < 1 and (is_package_dir('.') or is_project_dir('.')): if len(args) < 1 and (is_package_dir('.') or is_project_dir('.')):
@ -6145,7 +6145,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
repositories = [] repositories = []
# store list of repos for potential offline use # store list of repos for potential offline use
repolistfile = os.path.join(os.getcwd(), store, "_build_repositories") repolistfile = os.path.join(Path.cwd(), store, "_build_repositories")
if noinit: if noinit:
repositories = Repo.fromfile(repolistfile) repositories = Repo.fromfile(repolistfile)
else: else:
@ -6208,7 +6208,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if noinit: if noinit:
bc_filename = '_buildconfig-%s-%s' % (arg_repository, arg_arch) bc_filename = '_buildconfig-%s-%s' % (arg_repository, arg_arch)
if is_package_dir('.'): if is_package_dir('.'):
bc_filename = os.path.join(os.getcwd(), store, bc_filename) bc_filename = os.path.join(Path.cwd(), store, bc_filename)
else: else:
bc_filename = os.path.abspath(bc_filename) bc_filename = os.path.abspath(bc_filename)
if not os.path.isfile(bc_filename): if not os.path.isfile(bc_filename):
@ -6224,9 +6224,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if recipe == 'arch': if recipe == 'arch':
recipe = 'PKGBUILD' recipe = 'PKGBUILD'
recipe = decode_it(recipe) recipe = decode_it(recipe)
pac = os.path.basename(os.getcwd()) pac = os.path.basename(Path.cwd())
if is_package_dir(os.getcwd()): if is_package_dir(Path.cwd()):
pac = store_read_package(os.getcwd()) pac = store_read_package(Path.cwd())
if multibuild_package: if multibuild_package:
pac = multibuild_package pac = multibuild_package
if recipe == 'PKGBUILD': if recipe == 'PKGBUILD':
@ -6461,19 +6461,19 @@ Please submit there instead, or use --nodevelproject to force direct submission.
project = None project = None
try: try:
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
if project == opts.alternative_project: if project == opts.alternative_project:
opts.alternative_project = None opts.alternative_project = None
except oscerr.NoWorkingCopy: except oscerr.NoWorkingCopy:
# This may be a project managed entirely via git? # This may be a project managed entirely via git?
if os.path.isdir(os.curdir + "/../.osc") and os.path.isdir(os.curdir + "/../.git"): if os.path.isdir(Path.cwd() + "/../.osc") and os.path.isdir(Path.cwd() + "/../.git"):
project = store_read_project(os.curdir + "/..") project = store_read_project(Path.cwd() + "/..")
opts.alternative_project = project opts.alternative_project = project
pass pass
if len(args) == 0 and is_package_dir(os.curdir): if len(args) == 0 and is_package_dir(Path.cwd()):
# build env not specified, just read from last build attempt # build env not specified, just read from last build attempt
lastbuildroot = store_read_last_buildroot(os.curdir) lastbuildroot = store_read_last_buildroot(Path.cwd())
if lastbuildroot: if lastbuildroot:
args = [lastbuildroot[0], lastbuildroot[1]] args = [lastbuildroot[0], lastbuildroot[1]]
if not opts.vm_type: if not opts.vm_type:
@ -6510,7 +6510,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if not opts.local_package: if not opts.local_package:
try: try:
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
prj = Project(os.pardir, getPackageList=False, wc_check=False) prj = Project(os.pardir, getPackageList=False, wc_check=False)
if prj.status(package) == 'A': if prj.status(package) == 'A':
# a package with state 'A' most likely does not exist on # a package with state 'A' most likely does not exist on
@ -6592,7 +6592,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
return 0 return 0
cwd = os.getcwd() cwd = Path.cwd()
basename = os.path.basename(cwd) basename = os.path.basename(cwd)
if ':' not in opts.host: if ':' not in opts.host:
hostname = opts.host hostname = opts.host
@ -6713,7 +6713,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
repository = args[2] repository = args[2]
arch = args[3] arch = args[3]
elif len(args) == 2: elif len(args) == 2:
wd = os.curdir wd = Path.cwd()
package = store_read_package(wd) package = store_read_package(wd)
project = store_read_project(wd) project = store_read_project(wd)
repository = args[0] repository = args[0]
@ -6748,7 +6748,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
osc jobhist REPOSITORY ARCHITECTURE (in project dir) osc jobhist REPOSITORY ARCHITECTURE (in project dir)
osc jobhist PROJECT [PACKAGE[:FLAVOR]] REPOSITORY ARCHITECTURE osc jobhist PROJECT [PACKAGE[:FLAVOR]] REPOSITORY ARCHITECTURE
""" """
wd = os.curdir wd = Path.cwd()
args = slash_split(args) args = slash_split(args)
if len(args) < 2 and (is_project_dir('.') or is_package_dir('.')): if len(args) < 2 and (is_project_dir('.') or is_package_dir('.')):
@ -6810,7 +6810,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
apiurl = self.get_api_url() apiurl = self.get_api_url()
if len(args) == 0: if len(args) == 0:
wd = os.curdir wd = Path.cwd()
if is_project_dir(wd) or is_package_dir(wd): if is_project_dir(wd) or is_package_dir(wd):
project = store_read_project(wd) project = store_read_project(wd)
if is_project_dir(wd): if is_project_dir(wd):
@ -6888,15 +6888,15 @@ Please submit there instead, or use --nodevelproject to force direct submission.
raise oscerr.WrongArgs('No command given.') raise oscerr.WrongArgs('No command given.')
elif len(args) < 3: elif len(args) < 3:
if args[0] in remote_commands: if args[0] in remote_commands:
if not is_package_dir(os.curdir): if not is_package_dir(Path.cwd()):
msg = ('Either specify the project and package or execute ' msg = ('Either specify the project and package or execute '
'the command in a package working copy.') 'the command in a package working copy.')
raise oscerr.WrongArgs(msg) raise oscerr.WrongArgs(msg)
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
else: else:
# raise an appropriate exception if os.curdir is no package wc # raise an appropriate exception if Path.cwd() is no package wc
store_read_package(os.curdir) store_read_package(Path.cwd())
if len(args) == 2: if len(args) == 2:
singleservice = args[1] singleservice = args[1]
elif len(args) == 3 and args[0] in remote_commands: elif len(args) == 3 and args[0] in remote_commands:
@ -6923,7 +6923,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
return return
if command in ('runall', 'ra', 'run', 'localrun', 'manualrun', 'disabledrun', 'lr', 'mr', 'dr', 'r'): if command in ('runall', 'ra', 'run', 'localrun', 'manualrun', 'disabledrun', 'lr', 'mr', 'dr', 'r'):
if not is_package_dir(os.curdir): if not is_package_dir(Path.cwd()):
raise oscerr.WrongArgs('Local directory is no package') raise oscerr.WrongArgs('Local directory is no package')
p = Package(".") p = Package(".")
if command in ("localrun", "lr"): if command in ("localrun", "lr"):
@ -6976,13 +6976,13 @@ Please submit there instead, or use --nodevelproject to force direct submission.
arch = opts.arch arch = opts.arch
if len(args) < 1: if len(args) < 1:
if is_package_dir(os.curdir): if is_package_dir(Path.cwd()):
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
apiurl = store_read_apiurl(os.curdir) apiurl = store_read_apiurl(Path.cwd())
elif is_project_dir(os.curdir): elif is_project_dir(Path.cwd()):
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
apiurl = store_read_apiurl(os.curdir) apiurl = store_read_apiurl(Path.cwd())
else: else:
raise oscerr.WrongArgs('Too few arguments.') raise oscerr.WrongArgs('Too few arguments.')
else: else:
@ -7044,10 +7044,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
apiurl = self.get_api_url() apiurl = self.get_api_url()
if len(args) < 4: if len(args) < 4:
if is_package_dir(os.curdir): if is_package_dir(Path.cwd()):
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
apiurl = store_read_apiurl(os.curdir) apiurl = store_read_apiurl(Path.cwd())
repo = args[0] repo = args[0]
arch = args[1] arch = args[1]
sysrq = args[2] sysrq = args[2]
@ -7099,13 +7099,13 @@ Please submit there instead, or use --nodevelproject to force direct submission.
arch = opts.arch arch = opts.arch
if len(args) < 1: if len(args) < 1:
if is_package_dir(os.curdir): if is_package_dir(Path.cwd()):
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
apiurl = store_read_apiurl(os.curdir) apiurl = store_read_apiurl(Path.cwd())
elif is_project_dir(os.curdir): elif is_project_dir(Path.cwd()):
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
apiurl = store_read_apiurl(os.curdir) apiurl = store_read_apiurl(Path.cwd())
else: else:
raise oscerr.WrongArgs('Too few arguments.') raise oscerr.WrongArgs('Too few arguments.')
else: else:
@ -7168,11 +7168,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
# try to get project and package from checked out dirs # try to get project and package from checked out dirs
if len(args) < 1: if len(args) < 1:
if is_project_dir(os.getcwd()): if is_project_dir(Path.cwd()):
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
if is_package_dir(os.getcwd()): if is_package_dir(Path.cwd()):
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
if project is None: if project is None:
raise oscerr.WrongArgs('Missing <project> argument.') raise oscerr.WrongArgs('Missing <project> argument.')
if len(args) > 2: if len(args) > 2:
@ -7250,7 +7250,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
package = None package = None
binary = None binary = None
if opts.multibuild_package and ((len(args) > 2) or (len(args) <= 2 and is_project_dir(os.getcwd()))): if opts.multibuild_package and ((len(args) > 2) or (len(args) <= 2 and is_project_dir(Path.cwd()))):
self.argparse_error("The -M/--multibuild-package option can be only used from a package checkout.") self.argparse_error("The -M/--multibuild-package option can be only used from a package checkout.")
if len(args) < 1 and is_package_dir('.'): if len(args) < 1 and is_package_dir('.'):
@ -7267,11 +7267,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
elif len(args) == 3: elif len(args) == 3:
project, repository, architecture = args project, repository, architecture = args
elif len(args) >= 1 and len(args) <= 2: elif len(args) >= 1 and len(args) <= 2:
if is_package_dir(os.getcwd()): if is_package_dir(Path.cwd()):
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
elif is_project_dir(os.getcwd()): elif is_project_dir(Path.cwd()):
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
else: else:
raise oscerr.WrongArgs('Missing arguments: either specify <project> and ' raise oscerr.WrongArgs('Missing arguments: either specify <project> and '
'<package> or move to a project or package working copy') '<package> or move to a project or package working copy')
@ -7887,7 +7887,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if opts.project: if opts.project:
project_dir = opts.project project_dir = opts.project
else: else:
project_dir = os.curdir project_dir = Path.cwd()
if not is_project_dir(project_dir): if not is_project_dir(project_dir):
raise oscerr.WrongArgs("'%s' is no project working copy" % project_dir) raise oscerr.WrongArgs("'%s' is no project working copy" % project_dir)
@ -8371,7 +8371,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
apiurl = self.get_api_url() apiurl = self.get_api_url()
project = None project = None
project_dir = os.curdir project_dir = Path.cwd()
if is_project_dir(project_dir): if is_project_dir(project_dir):
project = store_read_project(project_dir) project = store_read_project(project_dir)
elif is_package_dir(project_dir): elif is_package_dir(project_dir):
@ -8427,9 +8427,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
project = self._process_project_name(args[0]) project = self._process_project_name(args[0])
package = args[1] package = args[1]
filename = args[2] filename = args[2]
elif len(args) == 1 and is_package_dir(os.getcwd()): elif len(args) == 1 and is_package_dir(Path.cwd()):
project = store_read_project(os.curdir) project = store_read_project(Path.cwd())
package = store_read_package(os.curdir) package = store_read_package(Path.cwd())
filename = args[0] filename = args[0]
else: else:
raise oscerr.WrongArgs('Wrong number of arguments.') raise oscerr.WrongArgs('Wrong number of arguments.')
@ -8504,9 +8504,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
elif len(args) == 2: elif len(args) == 2:
target_prj = prj = self._process_project_name(args[0]) target_prj = prj = self._process_project_name(args[0])
target_package = package = args[1] target_package = package = args[1]
elif is_package_dir(os.getcwd()): elif is_package_dir(Path.cwd()):
target_prj = prj = store_read_project(os.getcwd()) target_prj = prj = store_read_project(Path.cwd())
target_package = package = store_read_package(os.getcwd()) target_package = package = store_read_package(Path.cwd())
else: else:
raise oscerr.WrongArgs('Please specify project and package') raise oscerr.WrongArgs('Please specify project and package')
@ -8837,7 +8837,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
prj = None prj = None
if len(args) == 0: if len(args) == 0:
cwd = os.getcwd() cwd = Path.cwd()
if is_project_dir(cwd) or is_package_dir(cwd): if is_project_dir(cwd) or is_package_dir(cwd):
prj = store_read_project(cwd) prj = store_read_project(cwd)
if len(args) == 1: if len(args) == 1: