mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-09 00:40:11 +01:00
Merge branch 'replace_optparse_with_argparse' into 'master'
replace deprecated optparse with argparse squashed and rebased merge request fdroid/fdroidserver!74 following guidelines from: https://docs.python.org/2/library/argparse.html#upgrading-optparse-code except, still using option = parse.parse_args() instead of args = ... - using the following script in folder fdroidserver: ``` for i in *.py; do sed -i -e 's/optparse/argparse/' \ -e 's/OptionParser/ArgumentParser/' \ -e 's/OptionError/ArgumentError/' \ -e 's/add_option/add_argument/' \ -e 's/(options, args) = parser/options = parser/' \ -e 's/options, args = parser/options = parser/' \ -e 's/Usage: %prog/%(prog)s/' $i; done ``` - use ArgumentParser argument to replace (option, args) = parser.parse() call - use parser.error(msg) instead of raise ArgumentException as suggested in https://docs.python.org/2/library/argparse.html#exiting-methods - in fdroid catch ArgumentError instead of OptionError See merge request !75
This commit is contained in:
commit
9489e80f09
4
fdroid
4
fdroid
@ -22,7 +22,7 @@ import sys
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import fdroidserver.common
|
import fdroidserver.common
|
||||||
from optparse import OptionError
|
from argparse import ArgumentError
|
||||||
|
|
||||||
commands = {
|
commands = {
|
||||||
"build": "Build a package from source",
|
"build": "Build a package from source",
|
||||||
@ -124,7 +124,7 @@ def main():
|
|||||||
else:
|
else:
|
||||||
logging.critical(str(e))
|
logging.critical(str(e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
except OptionError, e:
|
except ArgumentError as e:
|
||||||
logging.critical(str(e))
|
logging.critical(str(e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
@ -29,7 +29,7 @@ import traceback
|
|||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
from ConfigParser import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
from optparse import OptionParser, OptionError
|
from argparse import ArgumentParser
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -932,47 +932,48 @@ def trybuild(app, thisbuild, build_dir, output_dir, also_check_dir, srclib_dir,
|
|||||||
|
|
||||||
|
|
||||||
def parse_commandline():
|
def parse_commandline():
|
||||||
"""Parse the command line. Returns options, args."""
|
"""Parse the command line. Returns options, parser."""
|
||||||
|
|
||||||
parser = OptionParser(usage="Usage: %prog [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]")
|
parser = ArgumentParser(usage="%(prog)s [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("appid", nargs='*', help="app-id with optional versioncode in the form APPID[:VERCODE]")
|
||||||
help="Spew out even more information than normal")
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
help="Spew out even more information than normal")
|
||||||
help="Restrict output to warnings and errors")
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
parser.add_option("-l", "--latest", action="store_true", default=False,
|
help="Restrict output to warnings and errors")
|
||||||
help="Build only the latest version of each package")
|
parser.add_argument("-l", "--latest", action="store_true", default=False,
|
||||||
parser.add_option("-s", "--stop", action="store_true", default=False,
|
help="Build only the latest version of each package")
|
||||||
help="Make the build stop on exceptions")
|
parser.add_argument("-s", "--stop", action="store_true", default=False,
|
||||||
parser.add_option("-t", "--test", action="store_true", default=False,
|
help="Make the build stop on exceptions")
|
||||||
help="Test mode - put output in the tmp directory only, and always build, even if the output already exists.")
|
parser.add_argument("-t", "--test", action="store_true", default=False,
|
||||||
parser.add_option("--server", action="store_true", default=False,
|
help="Test mode - put output in the tmp directory only, and always build, even if the output already exists.")
|
||||||
help="Use build server")
|
parser.add_argument("--server", action="store_true", default=False,
|
||||||
parser.add_option("--resetserver", action="store_true", default=False,
|
help="Use build server")
|
||||||
help="Reset and create a brand new build server, even if the existing one appears to be ok.")
|
parser.add_argument("--resetserver", action="store_true", default=False,
|
||||||
parser.add_option("--on-server", dest="onserver", action="store_true", default=False,
|
help="Reset and create a brand new build server, even if the existing one appears to be ok.")
|
||||||
help="Specify that we're running on the build server")
|
parser.add_argument("--on-server", dest="onserver", action="store_true", default=False,
|
||||||
parser.add_option("--skip-scan", dest="skipscan", action="store_true", default=False,
|
help="Specify that we're running on the build server")
|
||||||
help="Skip scanning the source code for binaries and other problems")
|
parser.add_argument("--skip-scan", dest="skipscan", action="store_true", default=False,
|
||||||
parser.add_option("--no-tarball", dest="notarball", action="store_true", default=False,
|
help="Skip scanning the source code for binaries and other problems")
|
||||||
help="Don't create a source tarball, useful when testing a build")
|
parser.add_argument("--no-tarball", dest="notarball", action="store_true", default=False,
|
||||||
parser.add_option("--no-refresh", dest="refresh", action="store_false", default=True,
|
help="Don't create a source tarball, useful when testing a build")
|
||||||
help="Don't refresh the repository, useful when testing a build with no internet connection")
|
parser.add_argument("--no-refresh", dest="refresh", action="store_false", default=True,
|
||||||
parser.add_option("-f", "--force", action="store_true", default=False,
|
help="Don't refresh the repository, useful when testing a build with no internet connection")
|
||||||
help="Force build of disabled apps, and carries on regardless of scan problems. Only allowed in test mode.")
|
parser.add_argument("-f", "--force", action="store_true", default=False,
|
||||||
parser.add_option("-a", "--all", action="store_true", default=False,
|
help="Force build of disabled apps, and carries on regardless of scan problems. Only allowed in test mode.")
|
||||||
help="Build all applications available")
|
parser.add_argument("-a", "--all", action="store_true", default=False,
|
||||||
parser.add_option("-w", "--wiki", default=False, action="store_true",
|
help="Build all applications available")
|
||||||
help="Update the wiki")
|
parser.add_argument("-w", "--wiki", default=False, action="store_true",
|
||||||
options, args = parser.parse_args()
|
help="Update the wiki")
|
||||||
|
options = parser.parse_args()
|
||||||
|
|
||||||
# Force --stop with --on-server to get correct exit code
|
# Force --stop with --on-server to get correct exit code
|
||||||
if options.onserver:
|
if options.onserver:
|
||||||
options.stop = True
|
options.stop = True
|
||||||
|
|
||||||
if options.force and not options.test:
|
if options.force and not options.test:
|
||||||
raise OptionError("Force is only allowed in test mode", "force")
|
parser.error("option %s: Force is only allowed in test mode" % "force")
|
||||||
|
|
||||||
return options, args
|
return options, parser
|
||||||
|
|
||||||
options = None
|
options = None
|
||||||
config = None
|
config = None
|
||||||
@ -982,16 +983,16 @@ def main():
|
|||||||
|
|
||||||
global options, config
|
global options, config
|
||||||
|
|
||||||
options, args = parse_commandline()
|
options, parser = parse_commandline()
|
||||||
if not args and not options.all:
|
if not options.appid and not options.all:
|
||||||
raise OptionError("If you really want to build all the apps, use --all", "all")
|
parser.error("option %s: If you really want to build all the apps, use --all" % "all")
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
if config['build_server_always']:
|
if config['build_server_always']:
|
||||||
options.server = True
|
options.server = True
|
||||||
if options.resetserver and not options.server:
|
if options.resetserver and not options.server:
|
||||||
raise OptionError("Using --resetserver without --server makes no sense", "resetserver")
|
parser.error("option %s: Using --resetserver without --server makes no sense" % "resetserver")
|
||||||
|
|
||||||
log_dir = 'logs'
|
log_dir = 'logs'
|
||||||
if not os.path.isdir(log_dir):
|
if not os.path.isdir(log_dir):
|
||||||
@ -1028,7 +1029,7 @@ def main():
|
|||||||
# Read all app and srclib metadata
|
# Read all app and srclib metadata
|
||||||
allapps = metadata.read_metadata(xref=not options.onserver)
|
allapps = metadata.read_metadata(xref=not options.onserver)
|
||||||
|
|
||||||
apps = common.read_app_args(args, allapps, True)
|
apps = common.read_app_args(options.appid, allapps, True)
|
||||||
for appid, app in apps.items():
|
for appid, app in apps.items():
|
||||||
if (app['Disabled'] and not options.force) or not app['Repo Type'] or not app['builds']:
|
if (app['Disabled'] and not options.force) or not app['Repo Type'] or not app['builds']:
|
||||||
del apps[appid]
|
del apps[appid]
|
||||||
|
@ -24,7 +24,7 @@ import re
|
|||||||
import urllib2
|
import urllib2
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import traceback
|
import traceback
|
||||||
import HTMLParser
|
import HTMLParser
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
@ -520,27 +520,28 @@ def main():
|
|||||||
global config, options
|
global config, options
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser(usage="Usage: %prog [options] [APPID [APPID ...]]")
|
parser = ArgumentParser(usage="%(prog)s [options] [APPID [APPID ...]]")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("appid", nargs='*', help="app-id to check for updates")
|
||||||
help="Spew out even more information than normal")
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
help="Spew out even more information than normal")
|
||||||
help="Restrict output to warnings and errors")
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
parser.add_option("--auto", action="store_true", default=False,
|
help="Restrict output to warnings and errors")
|
||||||
help="Process auto-updates")
|
parser.add_argument("--auto", action="store_true", default=False,
|
||||||
parser.add_option("--autoonly", action="store_true", default=False,
|
help="Process auto-updates")
|
||||||
help="Only process apps with auto-updates")
|
parser.add_argument("--autoonly", action="store_true", default=False,
|
||||||
parser.add_option("--commit", action="store_true", default=False,
|
help="Only process apps with auto-updates")
|
||||||
help="Commit changes")
|
parser.add_argument("--commit", action="store_true", default=False,
|
||||||
parser.add_option("--gplay", action="store_true", default=False,
|
help="Commit changes")
|
||||||
help="Only print differences with the Play Store")
|
parser.add_argument("--gplay", action="store_true", default=False,
|
||||||
(options, args) = parser.parse_args()
|
help="Only print differences with the Play Store")
|
||||||
|
options = parser.parse_args()
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
# Get all apps...
|
# Get all apps...
|
||||||
allapps = metadata.read_metadata()
|
allapps = metadata.read_metadata()
|
||||||
|
|
||||||
apps = common.read_app_args(args, allapps, False)
|
apps = common.read_app_args(options.appid, allapps, False)
|
||||||
|
|
||||||
if options.gplay:
|
if options.gplay:
|
||||||
for app in apps:
|
for app in apps:
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import common
|
import common
|
||||||
@ -35,12 +35,12 @@ def main():
|
|||||||
global config, options
|
global config, options
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser(usage="Usage: %prog [options]")
|
parser = ArgumentParser(usage="%(prog)s [options]")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
help="Spew out even more information than normal")
|
help="Spew out even more information than normal")
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
help="Restrict output to warnings and errors")
|
help="Restrict output to warnings and errors")
|
||||||
(options, args) = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import urllib
|
import urllib
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
from ConfigParser import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
import logging
|
import logging
|
||||||
import common
|
import common
|
||||||
@ -75,18 +75,18 @@ def main():
|
|||||||
global config, options
|
global config, options
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser()
|
parser = ArgumentParser()
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
help="Spew out even more information than normal")
|
help="Spew out even more information than normal")
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
help="Restrict output to warnings and errors")
|
help="Restrict output to warnings and errors")
|
||||||
parser.add_option("-u", "--url", default=None,
|
parser.add_argument("-u", "--url", default=None,
|
||||||
help="Project URL to import from.")
|
help="Project URL to import from.")
|
||||||
parser.add_option("-s", "--subdir", default=None,
|
parser.add_argument("-s", "--subdir", default=None,
|
||||||
help="Path to main android project subdirectory, if not in root.")
|
help="Path to main android project subdirectory, if not in root.")
|
||||||
parser.add_option("--rev", default=None,
|
parser.add_argument("--rev", default=None,
|
||||||
help="Allows a different revision (or git branch) to be specified for the initial import")
|
help="Allows a different revision (or git branch) to be specified for the initial import")
|
||||||
(options, args) = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import re
|
|||||||
import shutil
|
import shutil
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import common
|
import common
|
||||||
@ -50,22 +50,22 @@ def main():
|
|||||||
global options, config
|
global options, config
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser()
|
parser = ArgumentParser()
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
help="Spew out even more information than normal")
|
help="Spew out even more information than normal")
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
help="Restrict output to warnings and errors")
|
help="Restrict output to warnings and errors")
|
||||||
parser.add_option("-d", "--distinguished-name", default=None,
|
parser.add_argument("-d", "--distinguished-name", default=None,
|
||||||
help="X.509 'Distiguished Name' used when generating keys")
|
help="X.509 'Distiguished Name' used when generating keys")
|
||||||
parser.add_option("--keystore", default=None,
|
parser.add_argument("--keystore", default=None,
|
||||||
help="Path to the keystore for the repo signing key")
|
help="Path to the keystore for the repo signing key")
|
||||||
parser.add_option("--repo-keyalias", default=None,
|
parser.add_argument("--repo-keyalias", default=None,
|
||||||
help="Alias of the repo signing key in the keystore")
|
help="Alias of the repo signing key in the keystore")
|
||||||
parser.add_option("--android-home", default=None,
|
parser.add_argument("--android-home", default=None,
|
||||||
help="Path to the Android SDK (sometimes set in ANDROID_HOME)")
|
help="Path to the Android SDK (sometimes set in ANDROID_HOME)")
|
||||||
parser.add_option("--no-prompt", action="store_true", default=False,
|
parser.add_argument("--no-prompt", action="store_true", default=False,
|
||||||
help="Do not prompt for Android SDK path, just fail")
|
help="Do not prompt for Android SDK path, just fail")
|
||||||
(options, args) = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
# find root install prefix
|
# find root install prefix
|
||||||
tmp = os.path.dirname(sys.argv[0])
|
tmp = os.path.dirname(sys.argv[0])
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
from optparse import OptionParser, OptionError
|
from argparse import ArgumentParser
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import common
|
import common
|
||||||
@ -49,17 +49,18 @@ def main():
|
|||||||
global options, config
|
global options, config
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser(usage="Usage: %prog [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]")
|
parser = ArgumentParser(usage="%(prog)s [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("appid", nargs='*', help="app-id with optional versioncode in the form APPID[:VERCODE]")
|
||||||
help="Spew out even more information than normal")
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
help="Spew out even more information than normal")
|
||||||
help="Restrict output to warnings and errors")
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
parser.add_option("-a", "--all", action="store_true", default=False,
|
help="Restrict output to warnings and errors")
|
||||||
help="Install all signed applications available")
|
parser.add_argument("-a", "--all", action="store_true", default=False,
|
||||||
(options, args) = parser.parse_args()
|
help="Install all signed applications available")
|
||||||
|
options = parser.parse_args()
|
||||||
|
|
||||||
if not args and not options.all:
|
if not options.appid and not options.all:
|
||||||
raise OptionError("If you really want to install all the signed apps, use --all", "all")
|
parser.error("option %s: If you really want to install all the signed apps, use --all" % "all")
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
@ -68,9 +69,9 @@ def main():
|
|||||||
logging.info("No signed output directory - nothing to do")
|
logging.info("No signed output directory - nothing to do")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if args:
|
if options.appid:
|
||||||
|
|
||||||
vercodes = common.read_pkg_args(args, True)
|
vercodes = common.read_pkg_args(options.appid, True)
|
||||||
apks = {appid: None for appid in vercodes}
|
apks = {appid: None for appid in vercodes}
|
||||||
|
|
||||||
# Get the signed apk with the highest vercode
|
# Get the signed apk with the highest vercode
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public Licen
|
# You should have received a copy of the GNU Affero General Public Licen
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
import common
|
import common
|
||||||
@ -150,18 +150,19 @@ def main():
|
|||||||
count['warn'] += 1
|
count['warn'] += 1
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser(usage="Usage: %prog [options] [APPID [APPID ...]]")
|
parser = ArgumentParser(usage="%(prog)s [options] [APPID [APPID ...]]")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("appid", nargs='*', help="app-id in the form APPID")
|
||||||
help="Spew out even more information than normal")
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
help="Spew out even more information than normal")
|
||||||
help="Restrict output to warnings and errors")
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
(options, args) = parser.parse_args()
|
help="Restrict output to warnings and errors")
|
||||||
|
options = parser.parse_args()
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
# Get all apps...
|
# Get all apps...
|
||||||
allapps = metadata.read_metadata(xref=True)
|
allapps = metadata.read_metadata(xref=True)
|
||||||
apps = common.read_app_args(args, allapps, False)
|
apps = common.read_app_args(options.appid, allapps, False)
|
||||||
|
|
||||||
filling_ucms = re.compile('^(Tags.*|RepoManifest.*)')
|
filling_ucms = re.compile('^(Tags.*|RepoManifest.*)')
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import md5
|
import md5
|
||||||
import glob
|
import glob
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import common
|
import common
|
||||||
@ -39,13 +39,14 @@ def main():
|
|||||||
global config, options
|
global config, options
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser(usage="Usage: %prog [options] "
|
parser = ArgumentParser(usage="%(prog)s [options] "
|
||||||
"[APPID[:VERCODE] [APPID[:VERCODE] ...]]")
|
"[APPID[:VERCODE] [APPID[:VERCODE] ...]]")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("appid", nargs='*', help="app-id with optional versioncode in the form APPID[:VERCODE]")
|
||||||
help="Spew out even more information than normal")
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
help="Spew out even more information than normal")
|
||||||
help="Restrict output to warnings and errors")
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
(options, args) = parser.parse_args()
|
help="Restrict output to warnings and errors")
|
||||||
|
options = parser.parse_args()
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ def main():
|
|||||||
# Nonetheless, to be sure, before publishing we check that there are no
|
# Nonetheless, to be sure, before publishing we check that there are no
|
||||||
# collisions, and refuse to do any publishing if that's the case...
|
# collisions, and refuse to do any publishing if that's the case...
|
||||||
allapps = metadata.read_metadata()
|
allapps = metadata.read_metadata()
|
||||||
vercodes = common.read_pkg_args(args, True)
|
vercodes = common.read_pkg_args(options.appid, True)
|
||||||
allaliases = []
|
allaliases = []
|
||||||
for appid in allapps:
|
for appid in allapps:
|
||||||
m = md5.new()
|
m = md5.new()
|
||||||
|
@ -17,18 +17,18 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import common
|
import common
|
||||||
import metadata
|
import metadata
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
parser = OptionParser(usage="Usage: %prog")
|
parser = ArgumentParser(usage="%(prog)s")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
help="Spew out even more information than normal")
|
help="Spew out even more information than normal")
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
help="Restrict output to warnings and errors")
|
help="Restrict output to warnings and errors")
|
||||||
parser.parse_args()
|
parser.parse_args()
|
||||||
common.read_config(None)
|
common.read_config(None)
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import logging
|
import logging
|
||||||
import common
|
import common
|
||||||
import metadata
|
import metadata
|
||||||
@ -33,18 +33,19 @@ def main():
|
|||||||
global config, options
|
global config, options
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser(usage="Usage: %prog [options] [APPID [APPID ...]]")
|
parser = ArgumentParser(usage="%(prog)s [options] [APPID [APPID ...]]")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("appid", nargs='*', help="app-id in the form APPID")
|
||||||
help="Spew out even more information than normal")
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
help="Spew out even more information than normal")
|
||||||
help="Restrict output to warnings and errors")
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
(options, args) = parser.parse_args()
|
help="Restrict output to warnings and errors")
|
||||||
|
options = parser.parse_args()
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
# Get all apps...
|
# Get all apps...
|
||||||
allapps = metadata.read_metadata(xref=True)
|
allapps = metadata.read_metadata(xref=True)
|
||||||
apps = common.read_app_args(args, allapps, False)
|
apps = common.read_app_args(options.appid, allapps, False)
|
||||||
|
|
||||||
for appid, app in apps.iteritems():
|
for appid, app in apps.iteritems():
|
||||||
metadatapath = app['metadatapath']
|
metadatapath = app['metadatapath']
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import traceback
|
import traceback
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import common
|
import common
|
||||||
@ -249,18 +249,19 @@ def main():
|
|||||||
global config, options
|
global config, options
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser(usage="Usage: %prog [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]")
|
parser = ArgumentParser(usage="%(prog)s [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("appid", nargs='*', help="app-id with optional versioncode in the form APPID[:VERCODE]")
|
||||||
help="Spew out even more information than normal")
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
help="Spew out even more information than normal")
|
||||||
help="Restrict output to warnings and errors")
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
(options, args) = parser.parse_args()
|
help="Restrict output to warnings and errors")
|
||||||
|
options = parser.parse_args()
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
# Read all app and srclib metadata
|
# Read all app and srclib metadata
|
||||||
allapps = metadata.read_metadata()
|
allapps = metadata.read_metadata()
|
||||||
apps = common.read_app_args(args, allapps, True)
|
apps = common.read_app_args(options.appid, allapps, True)
|
||||||
|
|
||||||
probcount = 0
|
probcount = 0
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ import os
|
|||||||
import paramiko
|
import paramiko
|
||||||
import pwd
|
import pwd
|
||||||
import subprocess
|
import subprocess
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import logging
|
import logging
|
||||||
import common
|
import common
|
||||||
|
|
||||||
@ -195,28 +195,25 @@ def main():
|
|||||||
global config, options
|
global config, options
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser()
|
parser = ArgumentParser()
|
||||||
parser.add_option("-i", "--identity-file", default=None,
|
parser.add_argument("command", help="command to execute, either 'init' or 'update'")
|
||||||
help="Specify an identity file to provide to SSH for rsyncing")
|
parser.add_argument("-i", "--identity-file", default=None,
|
||||||
parser.add_option("--local-copy-dir", default=None,
|
help="Specify an identity file to provide to SSH for rsyncing")
|
||||||
help="Specify a local folder to sync the repo to")
|
parser.add_argument("--local-copy-dir", default=None,
|
||||||
parser.add_option("--sync-from-local-copy-dir", action="store_true", default=False,
|
help="Specify a local folder to sync the repo to")
|
||||||
help="Before uploading to servers, sync from local copy dir")
|
parser.add_argument("--sync-from-local-copy-dir", action="store_true", default=False,
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
help="Before uploading to servers, sync from local copy dir")
|
||||||
help="Spew out even more information than normal")
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
help="Spew out even more information than normal")
|
||||||
help="Restrict output to warnings and errors")
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
parser.add_option("--no-checksum", action="store_true", default=False,
|
help="Restrict output to warnings and errors")
|
||||||
help="Don't use rsync checksums")
|
parser.add_argument("--no-checksum", action="store_true", default=False,
|
||||||
(options, args) = parser.parse_args()
|
help="Don't use rsync checksums")
|
||||||
|
options = parser.parse_args()
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
if len(args) != 1:
|
if options.command != 'init' and options.command != 'update':
|
||||||
logging.critical("Specify a single command")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if args[0] != 'init' and args[0] != 'update':
|
|
||||||
logging.critical("The only commands currently supported are 'init' and 'update'")
|
logging.critical("The only commands currently supported are 'init' and 'update'")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -288,7 +285,7 @@ def main():
|
|||||||
if config['per_app_repos']:
|
if config['per_app_repos']:
|
||||||
repo_sections += common.get_per_app_repos()
|
repo_sections += common.get_per_app_repos()
|
||||||
|
|
||||||
if args[0] == 'init':
|
if options.command == 'init':
|
||||||
ssh = paramiko.SSHClient()
|
ssh = paramiko.SSHClient()
|
||||||
ssh.load_system_host_keys()
|
ssh.load_system_host_keys()
|
||||||
for serverwebroot in config.get('serverwebroot', []):
|
for serverwebroot in config.get('serverwebroot', []):
|
||||||
@ -310,7 +307,7 @@ def main():
|
|||||||
sftp.mkdir(repo_path, mode=0755)
|
sftp.mkdir(repo_path, mode=0755)
|
||||||
sftp.close()
|
sftp.close()
|
||||||
ssh.close()
|
ssh.close()
|
||||||
elif args[0] == 'update':
|
elif options.command == 'update':
|
||||||
for repo_section in repo_sections:
|
for repo_section in repo_sections:
|
||||||
if local_copy_dir is not None:
|
if local_copy_dir is not None:
|
||||||
if config['sync_from_local_copy_dir'] and os.path.exists(repo_section):
|
if config['sync_from_local_copy_dir'] and os.path.exists(repo_section):
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import common
|
import common
|
||||||
@ -34,12 +34,12 @@ def main():
|
|||||||
global config, options
|
global config, options
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser(usage="Usage: %prog [options]")
|
parser = ArgumentParser(usage="%(prog)s [options]")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
help="Spew out even more information than normal")
|
help="Spew out even more information than normal")
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
help="Restrict output to warnings and errors")
|
help="Restrict output to warnings and errors")
|
||||||
(options, args) = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
import glob
|
import glob
|
||||||
import json
|
import json
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import paramiko
|
import paramiko
|
||||||
import socket
|
import socket
|
||||||
import logging
|
import logging
|
||||||
@ -50,19 +50,19 @@ def main():
|
|||||||
global options, config
|
global options, config
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser()
|
parser = ArgumentParser()
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
help="Spew out even more information than normal")
|
help="Spew out even more information than normal")
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
help="Restrict output to warnings and errors")
|
help="Restrict output to warnings and errors")
|
||||||
parser.add_option("-d", "--download", action="store_true", default=False,
|
parser.add_argument("-d", "--download", action="store_true", default=False,
|
||||||
help="Download logs we don't have")
|
help="Download logs we don't have")
|
||||||
parser.add_option("--recalc", action="store_true", default=False,
|
parser.add_argument("--recalc", action="store_true", default=False,
|
||||||
help="Recalculate aggregate stats - use when changes "
|
help="Recalculate aggregate stats - use when changes "
|
||||||
"have been made that would invalidate old cached data.")
|
"have been made that would invalidate old cached data.")
|
||||||
parser.add_option("--nologs", action="store_true", default=False,
|
parser.add_argument("--nologs", action="store_true", default=False,
|
||||||
help="Don't do anything logs-related")
|
help="Don't do anything logs-related")
|
||||||
(options, args) = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ import hashlib
|
|||||||
import pickle
|
import pickle
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from xml.dom.minidom import Document
|
from xml.dom.minidom import Document
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import time
|
import time
|
||||||
from pyasn1.error import PyAsn1Error
|
from pyasn1.error import PyAsn1Error
|
||||||
from pyasn1.codec.der import decoder, encoder
|
from pyasn1.codec.der import decoder, encoder
|
||||||
@ -1048,35 +1048,35 @@ def main():
|
|||||||
global config, options
|
global config, options
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser()
|
parser = ArgumentParser()
|
||||||
parser.add_option("--create-key", action="store_true", default=False,
|
parser.add_argument("--create-key", action="store_true", default=False,
|
||||||
help="Create a repo signing key in a keystore")
|
help="Create a repo signing key in a keystore")
|
||||||
parser.add_option("-c", "--create-metadata", action="store_true", default=False,
|
parser.add_argument("-c", "--create-metadata", action="store_true", default=False,
|
||||||
help="Create skeleton metadata files that are missing")
|
help="Create skeleton metadata files that are missing")
|
||||||
parser.add_option("--delete-unknown", action="store_true", default=False,
|
parser.add_argument("--delete-unknown", action="store_true", default=False,
|
||||||
help="Delete APKs without metadata from the repo")
|
help="Delete APKs without metadata from the repo")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
help="Spew out even more information than normal")
|
help="Spew out even more information than normal")
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
help="Restrict output to warnings and errors")
|
help="Restrict output to warnings and errors")
|
||||||
parser.add_option("-b", "--buildreport", action="store_true", default=False,
|
parser.add_argument("-b", "--buildreport", action="store_true", default=False,
|
||||||
help="Report on build data status")
|
help="Report on build data status")
|
||||||
parser.add_option("-i", "--interactive", default=False, action="store_true",
|
parser.add_argument("-i", "--interactive", default=False, action="store_true",
|
||||||
help="Interactively ask about things that need updating.")
|
help="Interactively ask about things that need updating.")
|
||||||
parser.add_option("-I", "--icons", action="store_true", default=False,
|
parser.add_argument("-I", "--icons", action="store_true", default=False,
|
||||||
help="Resize all the icons exceeding the max pixel size and exit")
|
help="Resize all the icons exceeding the max pixel size and exit")
|
||||||
parser.add_option("-e", "--editor", default="/etc/alternatives/editor",
|
parser.add_argument("-e", "--editor", default="/etc/alternatives/editor",
|
||||||
help="Specify editor to use in interactive mode. Default " +
|
help="Specify editor to use in interactive mode. Default " +
|
||||||
"is /etc/alternatives/editor")
|
"is /etc/alternatives/editor")
|
||||||
parser.add_option("-w", "--wiki", default=False, action="store_true",
|
parser.add_argument("-w", "--wiki", default=False, action="store_true",
|
||||||
help="Update the wiki")
|
help="Update the wiki")
|
||||||
parser.add_option("", "--pretty", action="store_true", default=False,
|
parser.add_argument("--pretty", action="store_true", default=False,
|
||||||
help="Produce human-readable index.xml")
|
help="Produce human-readable index.xml")
|
||||||
parser.add_option("--clean", action="store_true", default=False,
|
parser.add_argument("--clean", action="store_true", default=False,
|
||||||
help="Clean update - don't uses caches, reprocess all apks")
|
help="Clean update - don't uses caches, reprocess all apks")
|
||||||
parser.add_option("--nosign", action="store_true", default=False,
|
parser.add_argument("--nosign", action="store_true", default=False,
|
||||||
help="When configured for signed indexes, create only unsigned indexes at this stage")
|
help="When configured for signed indexes, create only unsigned indexes at this stage")
|
||||||
(options, args) = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import common
|
import common
|
||||||
@ -36,12 +36,13 @@ def main():
|
|||||||
global options, config
|
global options, config
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser(usage="Usage: %prog [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]")
|
parser = ArgumentParser(usage="%(prog)s [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_argument("appid", nargs='*', help="app-id with optional versioncode in the form APPID[:VERCODE]")
|
||||||
help="Spew out even more information than normal")
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
help="Spew out even more information than normal")
|
||||||
help="Restrict output to warnings and errors")
|
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||||
(options, args) = parser.parse_args()
|
help="Restrict output to warnings and errors")
|
||||||
|
options = parser.parse_args()
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ def main():
|
|||||||
verified = 0
|
verified = 0
|
||||||
notverified = 0
|
notverified = 0
|
||||||
|
|
||||||
vercodes = common.read_pkg_args(args, True)
|
vercodes = common.read_pkg_args(options.appid, True)
|
||||||
|
|
||||||
for apkfile in sorted(glob.glob(os.path.join(unsigned_dir, '*.apk'))):
|
for apkfile in sorted(glob.glob(os.path.join(unsigned_dir, '*.apk'))):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user