Kaydet (Commit) abb259bd authored tarafından root's avatar root

pep8 fixes

üst 845f6c83
......@@ -74,14 +74,14 @@ def configure(parameters='',
parameters,
sourceDir)
if get.CFLAGS():
args+=' -DCMAKE_C_FLAGS="{0} {1}"'.format(get.CFLAGS(),
"-m32" if get.buildTYPE() == "emul32" else "-m64")
args += ' -DCMAKE_C_FLAGS="{0} {1}"'.format(get.CFLAGS(),
"-m32" if get.buildTYPE() == "emul32" else "-m64")
if get.CXXFLAGS():
args+=' -DCMAKE_CXX_FLAGS="{0} {1}"'.format(get.CXXFLAGS(),
"-m32" if get.buildTYPE() == "emul32" else "-m64")
args += ' -DCMAKE_CXX_FLAGS="{0} {1}"'.format(get.CXXFLAGS(),
"-m32" if get.buildTYPE() == "emul32" else "-m64")
if get.LDFLAGS():
args+=' -DCMAKE_LD_FLAGS="{0}"'.format(get.LDFLAGS())
args += ' -DCMAKE_LD_FLAGS="{0}"'.format(get.LDFLAGS())
if system(args):
raise ConfigureError(_('Configure failed.'))
else:
......
......@@ -66,7 +66,8 @@ def configure(parameters='',
installPrefix='/{}'.format(get.defaultprefixDIR()), sourceDir='.'):
"""configure source with given Go parameters = "-DGo_BUILD_TYPE -DGo_CXX_FLAGS ... " """
if not can_access_file(join_path(sourceDir, 'main.go')):
raise ConfigureError(_('{} not found'.format("main.go")))
raise ConfigureError(_('{} not found'.format("main.go")))
def go(parameters=''):
"""use go command from actionsapi"""
......@@ -104,4 +105,5 @@ def install(parameters='', argument=''):
def rawInstall(parameters='', argument=''):
"""rawInstall not available. Using install function"""
raise RunTimeError(_('rawInstall function is not available for gotools. Use install function'))
raise RunTimeError(
_('rawInstall function is not available for gotools. Use install function'))
......@@ -33,17 +33,17 @@ def exportFlags():
if "INARY_BUILD_TYPE" in os.environ and os.environ['INARY_BUILD_TYPE']:
if os.environ['INARY_BUILD_TYPE'] == "emul32" or os.environ['INARY_BUILD_TYPE'] == "clang32":
os.environ['PKG_CONFIG_PATH'] = "/usr/lib32/pkgconfig"
if "INARY_USE_FLAGS" in os.environ and os.environ['INARY_USE_FLAGS']:
os.environ['LDFLAGS'] = values.build.ldflags
if os.environ['INARY_BUILD_TYPE'] == "emul32" or os.environ['INARY_BUILD_TYPE'] == "clang32":
os.environ['CFLAGS'] = values.build.cflags.replace("-fPIC", "")
os.environ['CXXFLAGS'] = values.build.cxxflags.replace("-fPIC", "")
else:
os.environ['CFLAGS'] = values.build.cflags
os.environ['CXXFLAGS'] = values.build.cxxflags
os.environ['HOST'] = values.build.host
os.environ['USER_LDFLAGS'] = values.build.ldflags
os.environ['JOBS'] = values.build.jobs
......
......@@ -163,7 +163,7 @@ class Install(AtomicOperation):
self.store_old_paths = None
self.old_path = None
self.trigger = inary.trigger.Trigger()
self.ask_reinstall=False
self.ask_reinstall = False
def install(self, ask_reinstall=True):
......@@ -267,8 +267,8 @@ class Install(AtomicOperation):
ctx.ui.warning(msg)
if not self.ignore_file_conflicts:
if not ctx.ui.confirm(
_('Do you want to overwrite it?')):
raise Error(msg)
_('Do you want to overwrite it?')):
raise Error(msg)
def check_operation(self):
......@@ -344,9 +344,11 @@ class Install(AtomicOperation):
fpath = util.join_path(ctx.config.dest_dir(), _file.path)
if os.path.islink(fpath):
if os.path.lexists(fpath) and os.path.exists(fpath):
ctx.ui.info(_("Added symlink '{}' ").format(fpath), verbose=True)
ctx.ui.info(_("Added symlink '{}' ").format(
fpath), verbose=True)
else:
ctx.ui.warning(_("Broken or missing symlink '{}'").format(fpath))
ctx.ui.warning(
_("Broken or missing symlink '{}'").format(fpath))
if 'postOps' in self.metadata.package.isA:
if ctx.config.get_option(
......@@ -451,7 +453,6 @@ class Install(AtomicOperation):
os.unlink(old_file_path)
continue
try:
old_file_stat = os.lstat(old_file_path)
except OSError:
......@@ -655,7 +656,7 @@ class Remove(AtomicOperation):
if not self.installdb.has_package(self.package_name):
ctx.ui.status(_('Trying to remove nonexistent package ')
+ self.package_name)
+ self.package_name)
self.check_dependencies()
if not ctx.config.get_option(
......
......@@ -43,7 +43,6 @@ NB: We support only local files (e.g., /a/b/c) and http:// URIs at the moment
super(AddRepo, self).__init__(args)
self.repodb = inary.db.repodb.RepoDB()
name = ("add-repo", "ar")
def options(self):
......
......@@ -80,7 +80,7 @@ Usage: check-relation
need_reinstall.append(p.package)
sys.stderr.write(
_("Missing: - {} : Needed by: - {}").format(p.package, pkg)+"\n")
if self.options.force:
for pkg in installed:
pkgname = pkg
......
......@@ -50,7 +50,8 @@ repositories.
self.init(database=True, write=False)
components = self.componentdb.list_components(ctx.get_option('repository'))
components = self.componentdb.list_components(
ctx.get_option('repository'))
if components:
maxlen = max([len(_p) for _p in components])
components.sort()
......
......@@ -58,10 +58,9 @@ Downloads the given inary packages to working directory
full_packages = []
for repo in self.args:
full_packages=packages.list_packages(repo)
full_packages = packages.list_packages(repo)
for pkgname in full_packages:
pkg,repo=packages.get_package_repo(pkgname,repo)
output=os.path.join(ctx.config.options.output_dir,os.path.dirname(pkg.packageURI))
fetcher.fetch([pkgname], output,repo)
pkg, repo = packages.get_package_repo(pkgname, repo)
output = os.path.join(
ctx.config.options.output_dir, os.path.dirname(pkg.packageURI))
fetcher.fetch([pkgname], output, repo)
......@@ -189,7 +189,7 @@ class Source(metaclass=autoxml.autoxml):
t_Version = [autoxml.String, autoxml.optional]
t_Release = [autoxml.String, autoxml.optional]
t_SourceURI = [autoxml.String, autoxml.optional] # used in index
t_UseFlag = [autoxml.String, autoxml.optional]
t_UseFlag = [autoxml.String, autoxml.optional]
def buildtimeDependencies(self):
return self.buildDependencies
......
......@@ -49,7 +49,7 @@ def regenerate_caches():
# Force cache regeneration
try:
for db in [packagedb.PackageDB(), sourcedb.SourceDB(), componentdb.ComponentDB(),
installdb.InstallDB(), historydb.HistoryDB(), groupdb.GroupDB(), repodb.RepoDB()]:
installdb.InstallDB(), historydb.HistoryDB(), groupdb.GroupDB(), repodb.RepoDB()]:
db.cache_regenerate()
except Exception: # TODO: warning message needed
except Exception: # TODO: warning message needed
pass
......@@ -49,17 +49,18 @@ class FilesDB(lazydb.LazyDB):
installdb = inary.db.installdb.InstallDB()
installed = installdb.list_installed()
installed.sort()
total=len(installed)
count=1
total = len(installed)
count = 1
for pkg in installed:
files = installdb.get_files(pkg)
self.add_files(pkg, files)
ctx.ui.info(
"%-80.80s\r" %
("{}/{} "+_('-> Adding files of \"{}\" package to db...')).format(total,count,pkg),
("{}/{} "+_('-> Adding files of \"{}\" package to db...')
).format(total, count, pkg),
noln=True,
color='brightpurple')
count+=1
count += 1
ctx.ui.info(_('\nAdded files database...'), color='green')
def get_file(self, path):
......
......@@ -139,7 +139,8 @@ class HistoryDB(lazydb.LazyDB):
yield hist.operation
def get_last_repo_update(self, last=1):
repoupdates = [log for log in self.__logs if log.endswith("repoupdate.xml")]
repoupdates = [
log for log in self.__logs if log.endswith("repoupdate.xml")]
repoupdates.reverse()
if last != 1 and len(repoupdates) <= last:
......
......@@ -412,7 +412,7 @@ class InstallDB(lazydb.LazyDB):
def get_rev_deps(self, name):
rev_deps = []
if not self.rev_deps_db:
self.rev_deps_db =self.__generate_revdeps()
self.rev_deps_db = self.__generate_revdeps()
package_revdeps = self.rev_deps_db.get(name)
if package_revdeps:
for pkg, dep in list(package_revdeps.items()):
......
......@@ -13,6 +13,7 @@
#
# Standart Python Modules
import gettext
import os
import time
import pickle
......@@ -25,7 +26,6 @@ import inary.util as util
lower_map = str.maketrans(util.ascii_uppercase, util.ascii_lowercase)
# Gettext Library
import gettext
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
......
......@@ -156,7 +156,7 @@ class RepoDB(lazydb.LazyDB):
self,
cacheable=False,
cachedir=ctx.config.packages_dir())
def init(self):
self.repoorder = RepoOrder()
......
......@@ -104,11 +104,11 @@ class SourceDB(lazydb.LazyDB):
def get_spec(self, name, repo=None):
spec, repo = self.get_spec_repo(name, repo)
return spec
def get_source_names(self,names,repo=None):
A=[]
def get_source_names(self, names, repo=None):
A = []
for x in names:
A.append(self.pkgtosrc(x,repo))
A.append(self.pkgtosrc(x, repo))
return A
def search_spec(self, terms, lang=None, repo=None, fields=None, cs=False):
......
......@@ -271,18 +271,18 @@ class Fetcher:
def _get_wget(self):
return os.system("busybox wget -c --user-agent \"{}\" \"{}\" -O \"{}\" 2>&1".format(
self.useragent,
self.url.get_uri(),
self.partial_file
)
self.useragent,
self.url.get_uri(),
self.partial_file
)
)
def _get_aria2c(self):
return os.system("aria2c -U \"{}\" -c \"{}\" -d \"/\" -o \"{}\"".format(
self.useragent,
self.url.get_uri(),
self.partial_file
)
self.useragent,
self.url.get_uri(),
self.partial_file
)
)
def _get_requests(self):
......@@ -494,7 +494,7 @@ def fetch_from_mirror(url, destdir=None, progress=None, destfile=None):
# Operation function
def fetch(packages=None, path=os.path.curdir,repo=None):
def fetch(packages=None, path=os.path.curdir, repo=None):
"""
Fetches the given packages from the repository without installing, just downloads the packages.
@param packages: list of package names -> list_of_strings
......@@ -506,7 +506,7 @@ def fetch(packages=None, path=os.path.curdir,repo=None):
packagedb = inary.db.packagedb.PackageDB()
repodb = inary.db.repodb.RepoDB()
for name in packages:
package, repo = packagedb.get_package_repo(name,repo)
package, repo = packagedb.get_package_repo(name, repo)
ctx.ui.info(
_("\"{0}\" package found in \"{1}\" repository.").format(
package.name, repo))
......
......@@ -209,18 +209,18 @@ class Builder:
_("Source \"{}\" not found in any active repository.").format(name))
def __init__(self, specuri):
self.emerge=False
self.emerge = False
if "://" in specuri:
self.emerge=True
self.emerge = True
self.componentdb = inary.db.componentdb.ComponentDB()
self.installdb = inary.db.installdb.InstallDB()
self.specuri=specuri
self.specuri = specuri
self.specdiruri = os.path.dirname(self.specuri)
if len(self.specdiruri) > 0 and self.emerge:
self.pkgname = os.path.basename(self.specdiruri)
self.destdir = util.join_path(ctx.config.tmp_dir(), self.pkgname)
else:
self.destdir=None
self.destdir = None
# process args
if not isinstance(specuri, inary.uri.URI):
......@@ -230,13 +230,12 @@ class Builder:
self.fetch_pspecfile()
# read spec file, we'll need it :)
self.spec = self.set_spec_file(specuri)
if specuri.is_remote_file():
self.specdir = self.fetch_files()
else:
self.specdir = os.path.dirname(self.specuri.get_uri())
# Don't wait until creating .inary file for complaining about versioning
# scheme errors
self.package_rfp = None
......@@ -284,17 +283,18 @@ class Builder:
self.has_ccache = False
self.has_icecream = False
self.variable_buffer = {}
self.destdir=os.getcwd()
self.destdir = os.getcwd()
def set_spec_file(self, specuri):
if not specuri.is_remote_file():
# FIXME: doesn't work for file://
specuri = inary.uri.URI(os.path.realpath(specuri.get_uri()))
self.specuri = specuri
spec = Specfile.SpecFile()
if self.emerge:
spec.read("{}/{}".format(self.destdir,ctx.const.pspec_file),self.specuri)
spec.read("{}/{}".format(self.destdir,
ctx.const.pspec_file), self.specuri)
else:
spec.read(self.specuri, ctx.config.tmp_dir())
return spec
......@@ -375,12 +375,12 @@ class Builder:
self.check_patches()
self.check_build_dependencies()
try:
self.fetch_component()
except:
ctx.ui.output(_("Component cannot readed.")+"\n")
self.fetch_source_archives()
util.clean_dir(self.pkg_install_dir())
......@@ -445,7 +445,7 @@ class Builder:
# Each time a builder is created we must reset
# environment. See bug #2575
username=os.environ["USER"]
username = os.environ["USER"]
os.environ.clear()
# inary.actionsapi.variables.initVariables()
......@@ -741,12 +741,12 @@ class Builder:
# we'll need our working directory after actionscript
# finished its work in the archive source directory.
curDir = os.getcwd()
command=""
command = ""
self.specdiruri = os.path.dirname(self.specuri.get_uri())
pkgname = os.path.basename(self.specdiruri)
self.destdir = util.join_path(ctx.config.tmp_dir(), pkgname)
if os.path.exists(self.destdir):
curDir=self.destdir
curDir = self.destdir
src_dir = self.pkg_src_dir()
self.set_environment_vars()
os.environ['WORK_DIR'] = src_dir
......@@ -755,7 +755,7 @@ class Builder:
os.environ['OPERATION'] = func
if os.getuid() != 0:
if os.system("fakeroot --version &>/dev/null") == 0:
command+="fakeroot "
command += "fakeroot "
if os.path.exists(src_dir):
os.chdir(src_dir)
else:
......@@ -1077,7 +1077,7 @@ package might be a good solution."))
ctx.ui.warning(
_("File \"{}\" might be a broken symlink. Check it before publishing package.".format(
filepath)
)
)
)
fileinfo = "broken symlink"
ctx.ui.info(
......@@ -1088,9 +1088,9 @@ package might be a good solution."))
"file {}".format(filepath), ui_debug=False)
if result[0]:
ctx.ui.error(_("\'file\' command failed with return code {0} for file: \"{1}\"").format(
result[0],
filepath) +
_("Output:\n{}").format(result[1])
result[0],
filepath) +
_("Output:\n{}").format(result[1])
)
fileinfo = str(result[1])
......
......@@ -55,7 +55,8 @@ def create_delta_packages_from_obj(old_packages, new_package_obj, specdir):
if old_pkg_info.release == new_pkg_info.release:
ctx.ui.warning(
_("Package \"{}\" has the same release number with the new package. Skipping it...").format(old_package)
_("Package \"{}\" has the same release number with the new package. Skipping it...").format(
old_package)
)
continue
......
......@@ -79,9 +79,9 @@ installed in the respective order to satisfy dependencies:
# Dependency install from source repo (fully emerge)
sourcedb = inary.db.sourcedb.SourceDB()
inary.operations.emerge.emerge(sourcedb.get_source_names(order_inst))
# Dependency install from binary repo (half emerge)
#for x in order_inst:
# for x in order_inst:
# atomicoperations.install_single_name(x)
# ctx.ui.notify(ui.packagestogo, order = order_build)
......@@ -121,7 +121,7 @@ def plan_emerge(A):
if not str(src.name) in G_f.vertices():
# TODO replace this shitty way with a function
G_f.packages.append(src.name)
def pkgtosrc(pkg):
return sourcedb.pkgtosrc(pkg)
......
......@@ -256,7 +256,8 @@ def show_changed_configs(package_dict, opt):
for package in package_dict:
if package_dict[package]:
if ctx.ui.confirm(util.colorize(
_("[?] Would you like to see changes in config files of \"{0}\" package").format(package),
_("[?] Would you like to see changes in config files of \"{0}\" package").format(
package),
color='brightyellow')):
for file in package_dict[package]:
new_file = util.join_path(
......
......@@ -134,13 +134,14 @@ def install_pkg_names(A, reinstall=False, extra=False):
str(" [ {:>" +
str(lndig) +
"} / {} ] => {}").format(paths.index(path) +
1, len(paths),pkg.metadata.package.name), color="yellow")
1, len(paths), pkg.metadata.package.name), color="yellow")
for file in pkg.files.list:
if file not in install_files:
install_files.append(file)
else:
file_conflicts.append(file)
ctx.ui.info(_("Current {} / Total {} files counted.").format(len(pkg.files.list),len(install_files)))
ctx.ui.info(
_("Current {} / Total {} files counted.").format(len(pkg.files.list), len(install_files)))
if len(file_conflicts) > 0:
ctx.ui.warning(_("Integration check error detected."))
for path in file_conflicts:
......@@ -163,7 +164,7 @@ def install_pkg_names(A, reinstall=False, extra=False):
str(" [ {:>" +
str(lndig) +
"} / {} ] => {}").format(paths.index(path) +
1, len(paths),util.basename(path)), color="yellow")
1, len(paths), util.basename(path)), color="yellow")
install_op.store_inary_files()
install_op.install(False)
try:
......
......@@ -86,9 +86,10 @@ def update_repos(repos, force=False):
updated = False
for repo in repos:
updated = __update_repo(repo, force)
if updated :
if updated:
inary.db.regenerate_caches()
@util.locked
def update_repo(repo, force=False):
inary.db.historydb.HistoryDB().create_history("repoupdate")
......
......@@ -227,7 +227,7 @@ def upgrade(A=None, repo=None):
lndig = math.floor(math.log(len(order), 10)) + 1
except ValueError:
lndig = 1
for x in order:
ctx.ui.info(_("Downloading") +
str(" [ {:>" +
......@@ -286,7 +286,8 @@ def plan_upgrade(A, force_replaced=True, replaces=None):
installdb = G_f.get_installdb()
packagedb = G_f.get_packagedb()
A = set(A) # Force upgrading of installed but replaced packages or else they will be removed (they are obsoleted also).
# Force upgrading of installed but replaced packages or else they will be removed (they are obsoleted also).
A = set(A)
# This is not wanted for a replaced driver package (eg. nvidia-X).
#
# FIXME: this is also not nice. this would not be needed if replaced packages are not written as obsoleted also.
......
......@@ -47,7 +47,8 @@ class Trigger:
else:
cmd_extra = " > /dev/null"
ret_val = os.system(
'bash --noprofile --norc -c \'source postoperations.sh ; if declare -F {0} &>/dev/null ; then {0} ; fi\''.format(func) + cmd_extra
'bash --noprofile --norc -c \'source postoperations.sh ; if declare -F {0} &>/dev/null ; then {0} ; fi\''.format(
func) + cmd_extra
)
os.chdir(curDir)
if (ret_val != 0):
......@@ -69,7 +70,8 @@ class Trigger:
cmd_extra = " > /dev/null"
ret_val = os.system(
'python3 -c \'import postoperations\nif(hasattr(postoperations,"{0}")):\n postoperations.{0}()\''.format(func) + cmd_extra
'python3 -c \'import postoperations\nif(hasattr(postoperations,"{0}")):\n postoperations.{0}()\''.format(
func) + cmd_extra
)
os.chdir(curDir)
if (ret_val != 0):
......
......@@ -33,4 +33,3 @@ def fs_sync():
ctx.ui.debug(
_("Filesystem syncing (It wouldn't be run whether nosync set with kernel parameters)"))
os.sync()
......@@ -86,5 +86,7 @@ def join_path(a, *p):
path += '/' + b
return path
def basename(path):
return path.split("/")[-1] # os.path.basename is not usefull for remote links
# os.path.basename is not usefull for remote links
return path.split("/")[-1]
......@@ -147,7 +147,7 @@ def human_readable_rate(size=0):
def format_by_columns(strings, sep_width=2):
if(len(strings)>0):
if(len(strings) > 0):
longest_str_len = len(max(strings, key=len))
else:
longest_str_len = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment