im.save(iconpath, "PNG")
except Exception as e:
- logging.error("Failed resizing {0} - {1}".format(iconpath, e))
+ logging.error(_("Failed resizing {path}: {error}".format(path=iconpath, error=e)))
finally:
if fp:
certs = [n for n in apk.namelist() if common.CERT_PATH_REGEX.match(n)]
if len(certs) < 1:
- logging.error("Found no signing certificates on %s" % apkpath)
+ logging.error(_("No signing certificates found in {path}").format(path=apkpath))
return None
if len(certs) > 1:
- logging.error("Found multiple signing certificates on %s" % apkpath)
+ logging.error(_("Found multiple signing certificates in {path}").format(path=apkpath))
return None
cert = apk.read(certs[0])
if (version.startswith('1.0.1') and len(version) > 5 and version[5] >= 'r') \
or (version.startswith('1.0.2') and len(version) > 5 and version[5] >= 'f') \
or re.match(r'[1-9]\.[1-9]\.[0-9].*', version):
- logging.debug('"%s" contains recent %s (%s)', filename, name, version)
+ logging.debug(_('"{path}" contains recent {name} ({version})')
+ .format(path=filename, name=name, version=version))
else:
- logging.warning('"%s" contains outdated %s (%s)', filename, name, version)
+ logging.warning(_('"{path}" contains outdated {name} ({version})')
+ .format(path=filename, name=name, version=version))
return True
break
elif name == 'AndroidManifest.xml' or name == 'classes.dex' or name.endswith('.so'):
"""
def obbWarnDelete(f, msg):
- logging.warning(msg + f)
+ logging.warning(msg + ' ' + f)
if options.delete_unknown:
- logging.error("Deleting unknown file: " + f)
+ logging.error(_("Deleting unknown file: {path}").format(path=f))
os.remove(f)
obbs = []
# obbfile looks like: [main|patch].<expansion-version>.<package-name>.obb
chunks = obbfile.split('.')
if chunks[0] != 'main' and chunks[0] != 'patch':
- obbWarnDelete(f, 'OBB filename must start with "main." or "patch.": ')
+ obbWarnDelete(f, _('OBB filename must start with "main." or "patch.":'))
continue
if not re.match(r'^-?[0-9]+$', chunks[1]):
- obbWarnDelete('The OBB version code must come after "' + chunks[0] + '.": ')
+ obbWarnDelete(f, _('The OBB version code must come after "{name}.":')
+ .format(name=chunks[0]))
continue
versionCode = int(chunks[1])
packagename = ".".join(chunks[2:-1])
highestVersionCode = java_Integer_MIN_VALUE
if packagename not in currentPackageNames:
- obbWarnDelete(f, "OBB's packagename does not match a supported APK: ")
+ obbWarnDelete(f, _("OBB's packagename does not match a supported APK:"))
continue
for apk in apks:
if packagename == apk['packageName'] and apk['versionCode'] > highestVersionCode:
highestVersionCode = apk['versionCode']
if versionCode > highestVersionCode:
- obbWarnDelete(f, 'OBB file has newer versionCode(' + str(versionCode)
- + ') than any APK: ')
+ obbWarnDelete(f, _('OBB file has newer versionCode({integer}) than any APK:')
+ .format(integer=str(versionCode)))
continue
obbsha256 = sha256sum(f)
obbs.append((packagename, versionCode, obbfile, obbsha256))
filename = os.path.join(repodir, name)
name_utf8 = name.decode('utf-8')
if filename.endswith(b'_src.tar.gz'):
- logging.debug('skipping source tarball: ' + filename.decode('utf-8'))
+ logging.debug(_('skipping source tarball: {path}')
+ .format(path=filename.decode('utf-8')))
continue
if not common.is_repo_file(filename):
continue
stat = os.stat(filename)
if stat.st_size == 0:
- raise FDroidException(filename + ' is zero size!')
+ raise FDroidException(_('{path} is zero size!')
+ .format(path=filename))
shasum = sha256sum(filename)
usecache = False
else:
repo_file['added'] = datetime(*a[:6])
if repo_file.get('hash') == shasum:
- logging.debug("Reading " + name_utf8 + " from cache")
+ logging.debug(_("Reading {apkfilename} from cache")
+ .format(apkfilename=name_utf8))
usecache = True
else:
- logging.debug("Ignoring stale cache data for " + name_utf8)
+ logging.debug(_("Ignoring stale cache data for {apkfilename}")
+ .format(apkfilename=name_utf8))
if not usecache:
logging.debug(_("Processing {apkfilename}").format(apkfilename=name_utf8))
if p.returncode != 0:
if options.delete_unknown:
if os.path.exists(apkfile):
- logging.error("Failed to get apk information, deleting " + apkfile)
+ logging.error(_("Failed to get apk information, deleting {path}").format(path=apkfile))
os.remove(apkfile)
else:
logging.error("Could not find {0} to remove it".format(apkfile))
else:
- logging.error("Failed to get apk information, skipping " + apkfile)
- raise BuildException("Invalid APK")
+ logging.error(_("Failed to get apk information, skipping {path}").format(path=apkfile))
+ raise BuildException(_("Invalid APK"))
for line in p.output.splitlines():
if line.startswith("package:"):
try:
else:
if options.delete_unknown:
if os.path.exists(apkfile):
- logging.error("Failed to get apk information, deleting " + apkfile)
+ logging.error(_("Failed to get apk information, deleting {path}")
+ .format(path=apkfile))
os.remove(apkfile)
else:
- logging.error("Could not find {0} to remove it".format(apkfile))
+ logging.error(_("Could not find {path} to remove it")
+ .format(path=apkfile))
else:
- logging.error("Failed to get apk information, skipping " + apkfile)
- raise BuildException("Invaild APK")
+ logging.error(_("Failed to get apk information, skipping {path}")
+ .format(path=apkfile))
+ raise BuildException(_("Invalid APK"))
except ImportError:
raise FDroidException("androguard library is not installed and aapt not present")
except FileNotFoundError:
- logging.error("Could not open apk file for analysis")
- raise BuildException("Invalid APK")
+ logging.error(_("Could not open apk file for analysis"))
+ raise BuildException(_("Invalid APK"))
apk['packageName'] = apkobject.get_package()
apk['versionCode'] = int(apkobject.get_androidversion_code())
if apkfilename in apkcache:
apk = apkcache[apkfilename]
if apk.get('hash') == sha256sum(apkfile):
- logging.debug("Reading " + apkfilename + " from cache")
+ logging.debug(_("Reading {apkfilename} from cache")
+ .format(apkfilename=apkfilename))
usecache = True
else:
- logging.debug("Ignoring stale cache data for " + apkfilename)
+ logging.debug(_("Ignoring stale cache data for {apkfilename}")
+ .format(apkfilename=apkfilename))
if not usecache:
logging.debug(_("Processing {apkfilename}").format(apkfilename=apkfilename))
if skipapk:
if archive_bad_sig:
- logging.warning('Archiving "' + apkfilename + '" with invalid signature!')
+ logging.warning(_('Archiving {apkfilename} with invalid signature!')
+ .format(apkfilename=apkfilename))
move_apk_between_sections(repodir, 'archive', apk)
else:
- logging.warning('Skipping "' + apkfilename + '" with invalid signature!')
+ logging.warning(_('Skipping {apkfilename} with invalid signature!')
+ .format(apkfilename=apkfilename))
return True, None, False
apkzip = zipfile.ZipFile(apkfile, 'r')
# store timezone info
manifest = apkzip.getinfo('AndroidManifest.xml')
if manifest.date_time[1] == 0: # month can't be zero
- logging.debug('AndroidManifest.xml has no date')
+ logging.debug(_('AndroidManifest.xml has no date'))
else:
dt_obj = datetime(*manifest.date_time)
checkdt = dt_obj - timedelta(1)
empty_densities.remove(density)
break
except Exception as e:
- logging.warning("Failed reading {0} - {1}".format(icon_path, e))
+ logging.warning(_("Failed reading {path}: {error}")
+ .format(path=icon_path, error=e))
if apk['icons']:
apk['icon'] = icon_filename
else:
keepversions = defaultkeepversions
- logging.debug("Checking archiving for {0} - apks:{1}, keepversions:{2}, archapks:{3}"
- .format(appid, len(apks), keepversions, len(archapks)))
+ logging.debug(_("Checking archiving for {appid} - apks:{integer}, keepversions:{keep}, archapks:{arch}")
+ .format(appid=appid, integer=len(apks), keep=keepversions, arch=len(archapks)))
current_app_apks = filter_apk_list_sorted(apks)
if len(current_app_apks) > keepversions:
apks_per_app[apk['packageName']] = apk
if not os.path.exists(apk['per_app_icons']):
- logging.info('Adding new repo for only ' + apk['packageName'])
+ logging.info(_('Adding new repo for only {name}').format(name=apk['packageName']))
os.makedirs(apk['per_app_icons'])
apkpath = os.path.join(repodir, apk['apkName'])
metatxt,
flags=re.IGNORECASE | re.MULTILINE)
else:
- logging.warning(apk['packageName'] + ' does not have a name! Using package name instead.')
+ logging.warning(_('{appid} does not have a name! Using package name instead.')
+ .format(appid=apk['packageName']))
metatxt = re.sub(r'^(((Auto)?Name|Summary):).*$',
r'\1 ' + apk['packageName'],
metatxt,
if 'name' in apk and apk['name'] != '':
app['Name'] = apk['name']
else:
- logging.warning(apk['packageName'] + ' does not have a name! Using package name instead.')
+ logging.warning(_('{appid} does not have a name! Using package name instead.')
+ .format(appid=apk['packageName']))
app['Name'] = apk['packageName']
with open(os.path.join('metadata', apk['packageName'] + '.yml'), 'w') as f:
yaml.dump(app, f, default_flow_style=False)
- logging.info("Generated skeleton metadata for " + apk['packageName'])
+ logging.info(_("Generated skeleton metadata for {appid}").format(appid=apk['packageName']))
config = None
parser.add_argument("-I", "--icons", action="store_true", default=False,
help=_("Resize all the icons exceeding the max pixel size and exit"))
parser.add_argument("-e", "--editor", default="/etc/alternatives/editor",
- help=_("Specify editor to use in interactive mode. Default ") +
- "is /etc/alternatives/editor")
+ help=_("Specify editor to use in interactive mode. Default " +
+ "is {path}").format(path='/etc/alternatives/editor'))
parser.add_argument("-w", "--wiki", default=False, action="store_true",
help=_("Update the wiki"))
parser.add_argument("--pretty", action="store_true", default=False,
config = common.read_config(options)
if not ('jarsigner' in config and 'keytool' in config):
- raise FDroidException('Java JDK not found! Install in standard location or set java_paths!')
+ raise FDroidException(_('Java JDK not found! Install in standard location or set java_paths!'))
repodirs = ['repo']
if config['archive_older'] != 0:
for k in ['repo_icon', 'archive_icon']:
if k in config:
if not os.path.exists(config[k]):
- logging.critical(k + ' "' + config[k] + '" does not exist! Correct it in config.py.')
+ logging.critical(_('{name} "{path}" does not exist! Correct it in config.py.')
+ .format(name=k, path=config[k]))
sys.exit(1)
# if the user asks to create a keystore, do it now, reusing whatever it can
if options.create_key:
if os.path.exists(config['keystore']):
- logging.critical("Cowardily refusing to overwrite existing signing key setup!")
+ logging.critical(_("Cowardily refusing to overwrite existing signing key setup!"))
logging.critical("\t'" + config['keystore'] + "'")
sys.exit(1)
create_metadata_from_template(apk)
apps = metadata.read_metadata()
else:
- msg = apk['apkName'] + " (" + apk['packageName'] + ") has no metadata!"
+ msg = _("{apkfilename} ({appid}) has no metadata!") \
+ .format(apkfilename=apk['apkName'], appid=apk['packageName'])
if options.delete_unknown:
- logging.warn(msg + "\n\tdeleting: repo/" + apk['apkName'])
+ logging.warn(msg + '\n\t' + _("deleting: repo/{apkfilename}")
+ .format(apkfilename=apk['apkName']))
rmf = os.path.join(repodirs[0], apk['apkName'])
if not os.path.exists(rmf):
- logging.error("Could not find {0} to remove it".format(rmf))
+ logging.error(_("Could not find {path} to remove it").format(path=rmf))
else:
os.remove(rmf)
else:
- logging.warn(msg + "\n\tUse `fdroid update -c` to create it.")
+ logging.warn(msg + '\n\t' + _("Use `fdroid update -c` to create it."))
copy_triple_t_store_metadata(apps)
insert_obbs(repodirs[0], apps, apks)
if os.path.isdir(repodir):
index.make(appdict, [appid], apks, repodir, False)
else:
- logging.info('Skipping index generation for ' + appid)
+ logging.info(_('Skipping index generation for {appid}').format(appid=appid))
return
if len(repodirs) > 1: