def main(): global config, options # Parse command line... parser = OptionParser() parser.add_option("-v", "--verbose", action="store_true", default=False, help="Spew out even more information than normal") parser.add_option("-p", "--package", default=None, help="Process only the specified package") (options, args) = parser.parse_args() config = common.read_config(options) # Get all apps... apps = metadata.read_metadata(package=options.package, xref=False) if len(apps) == 0 and options.package: print "No such package" sys.exit(1) for app in apps: print "Writing " + app['id'] metadata.write_metadata(os.path.join('metadata', app['id']) + '.txt', app) print "Finished."
def identify_datatypes(get_in, delimiter, columns=[]): log = os.path.dirname(get_in) + '/' + os.path.splitext( os.path.basename(get_in))[0] + '_warns.log' with open(log, 'a+') as warn: column = [] for col in columns: col_name, col_dtype = col.split(':')[0:2] if 'datetime' in col_dtype: meta.write_logs( warn, 'INFO', 'Campo data encontrado ' + col_name, 'Campo datetime encontrado -' + col_name + ' ' + col_dtype) column.append(col_name) df = pd.read_csv(get_in, sep=delimiter, encoding='utf-8', infer_datetime_format=True, parse_dates=column).replace( '\r?\n', ' ', regex=True).replace(delimiter, ' ', regex=True) meta.write_metadata( df, os.path.dirname(get_in) + '/' + os.path.splitext(os.path.basename(get_in))[0].replace('_temp', '') + '_metadata.schema') return df
def main(): global config, options # Parse command line... parser = OptionParser(usage="Usage: %prog [options] [APPID [APPID ...]]") parser.add_option("-v", "--verbose", action="store_true", default=False, help="Spew out even more information than normal") parser.add_option("-q", "--quiet", action="store_true", default=False, help="Restrict output to warnings and errors") (options, args) = parser.parse_args() config = common.read_config(options) # Get all apps... allapps = metadata.read_metadata(xref=True) apps = common.read_app_args(args, allapps, False) for appid, app in apps.iteritems(): logging.info("Writing " + appid) metadata.write_metadata(os.path.join('metadata', appid) + '.txt', app) logging.info("Finished.")
def main(): global config, options # Parse command line... parser = ArgumentParser(usage="%(prog)s [options] [APPID [APPID ...]]") common.setup_global_opts(parser) parser.add_argument("-l", "--list", action="store_true", default=False, help="List files that would be reformatted") parser.add_argument("-t", "--to", default=None, help="Rewrite to a specific format") parser.add_argument("appid", nargs='*', help="app-id in the form APPID") options = parser.parse_args() config = common.read_config(options) # Get all apps... allapps = metadata.read_metadata(xref=True) apps = common.read_app_args(options.appid, allapps, False) if options.list and options.to is not None: parser.error("Cannot use --list and --to at the same time") supported = ['txt', 'yaml'] if options.to is not None and options.to not in supported: parser.error("Must give a valid format to --to") for appid, app in apps.iteritems(): base, ext = common.get_extension(app.metadatapath) if not options.to and ext not in supported: logging.info("Ignoring %s file at '%s'" % (ext, app.metadatapath)) continue to_ext = ext if options.to is not None: to_ext = options.to if options.list: if not proper_format(app): print app.metadatapath continue with open(base + '.' + to_ext, 'w') as f: metadata.write_metadata(to_ext, f, app) if ext != to_ext: os.remove(app.metadatapath) logging.debug("Finished.")
def checkupdates_app(app, first=True): # If a change is made, commitmsg should be set to a description of it. # Only if this is set will changes be written back to the metadata. commitmsg = None tag = None msg = None vercode = None noverok = False mode = app.UpdateCheckMode if mode.startswith('Tags'): pattern = mode[5:] if len(mode) > 4 else None (version, vercode, tag) = check_tags(app, pattern) msg = vercode elif mode == 'RepoManifest': (version, vercode) = check_repomanifest(app) msg = vercode elif mode.startswith('RepoManifest/'): tag = mode[13:] (version, vercode) = check_repomanifest(app, tag) msg = vercode elif mode == 'RepoTrunk': (version, vercode) = check_repotrunk(app) msg = vercode elif mode == 'HTTP': (version, vercode) = check_http(app) msg = vercode elif mode in ('None', 'Static'): version = None msg = 'Checking disabled' noverok = True else: version = None msg = 'Invalid update check method' if version and vercode and app.VercodeOperation: oldvercode = str(int(vercode)) op = app.VercodeOperation.replace("%c", oldvercode) vercode = str(eval(op)) logging.debug("Applied vercode operation: %s -> %s" % (oldvercode, vercode)) if version and any(version.startswith(s) for s in [ '${', # Gradle variable names '@string/', # Strings we could not resolve ]): version = "Unknown" updating = False if version is None: logmsg = "...{0} : {1}".format(app.id, msg) if noverok: logging.info(logmsg) else: logging.warn(logmsg) elif vercode == app.CurrentVersionCode: logging.info("...up to date") else: app.CurrentVersion = version app.CurrentVersionCode = str(int(vercode)) updating = True commitmsg = fetch_autoname(app, tag) if updating: name = common.getappname(app) ver = common.getcvname(app) logging.info('...updating to version %s' % ver) commitmsg = 'Update CV of %s to %s' % (name, ver) if options.auto: mode = app.AutoUpdateMode if mode in ('None', 'Static'): pass elif mode.startswith('Version '): pattern = mode[8:] if pattern.startswith('+'): try: suffix, pattern = pattern.split(' ', 1) except ValueError: raise MetaDataException("Invalid AUM: " + mode) else: suffix = '' gotcur = False latest = None for build in app.builds: if int(build.vercode) >= int(app.CurrentVersionCode): gotcur = True if not latest or int(build.vercode) > int(latest.vercode): latest = build if int(latest.vercode) > int(app.CurrentVersionCode): logging.info("Refusing to auto update, since the latest build is newer") if not gotcur: newbuild = copy.deepcopy(latest) newbuild.disable = False newbuild.vercode = app.CurrentVersionCode newbuild.version = app.CurrentVersion + suffix logging.info("...auto-generating build for " + newbuild.version) commit = pattern.replace('%v', newbuild.version) commit = commit.replace('%c', newbuild.vercode) newbuild.commit = commit app.builds.append(newbuild) name = common.getappname(app) ver = common.getcvname(app) commitmsg = "Update %s to %s" % (name, ver) else: logging.warn('Invalid auto update mode "' + mode + '" on ' + app.id) if commitmsg: metadatapath = os.path.join('metadata', app.id + '.txt') with open(metadatapath, 'w') as f: metadata.write_metadata('txt', f, app) if options.commit: logging.info("Commiting update for " + metadatapath) gitcmd = ["git", "commit", "-m", commitmsg] if 'auto_author' in config: gitcmd.extend(['--author', config['auto_author']]) gitcmd.extend(["--", metadatapath]) if subprocess.call(gitcmd) != 0: logging.error("Git commit failed") sys.exit(1)
def checkupdates_app(app, first=True): # If a change is made, commitmsg should be set to a description of it. # Only if this is set will changes be written back to the metadata. commitmsg = None tag = None msg = None vercode = None noverok = False mode = app['Update Check Mode'] if mode.startswith('Tags'): pattern = mode[5:] if len(mode) > 4 else None (version, vercode, tag) = check_tags(app, pattern) msg = vercode elif mode == 'RepoManifest': (version, vercode) = check_repomanifest(app) msg = vercode elif mode.startswith('RepoManifest/'): tag = mode[13:] (version, vercode) = check_repomanifest(app, tag) msg = vercode elif mode == 'RepoTrunk': (version, vercode) = check_repotrunk(app) msg = vercode elif mode == 'HTTP': (version, vercode) = check_http(app) msg = vercode elif mode in ('None', 'Static'): version = None msg = 'Checking disabled' noverok = True else: version = None msg = 'Invalid update check method' if first and version is None and vercode == "Couldn't find package ID": logging.warn("Couldn't find any version information. Looking for a subdir change...") new_subdir = check_changed_subdir(app) if new_subdir is None: logging.warn("Couldn't find any new subdir.") else: logging.warn("Trying a new subdir: %s" % new_subdir) new_build = {} metadata.fill_build_defaults(new_build) new_build['version'] = "Ignore" new_build['vercode'] = "-1" new_build['subdir'] = new_subdir app['builds'].append(new_build) return checkupdates_app(app, first=False) if version and vercode and app['Vercode Operation']: op = app['Vercode Operation'].replace("%c", str(int(vercode))) vercode = str(eval(op)) updating = False if version is None: logmsg = "...{0} : {1}".format(app['id'], msg) if noverok: logging.info(logmsg) else: logging.warn(logmsg) elif vercode == app['Current Version Code']: logging.info("...up to date") else: app['Current Version'] = version app['Current Version Code'] = str(int(vercode)) updating = True commitmsg = fetch_autoname(app, tag) if updating: name = common.getappname(app) ver = common.getcvname(app) logging.info('...updating to version %s' % ver) commitmsg = 'Update CV of %s to %s' % (name, ver) if options.auto: mode = app['Auto Update Mode'] if mode in ('None', 'Static'): pass elif mode.startswith('Version '): pattern = mode[8:] if pattern.startswith('+'): try: suffix, pattern = pattern.split(' ', 1) except ValueError: raise MetaDataException("Invalid AUM: " + mode) else: suffix = '' gotcur = False latest = None for build in app['builds']: if build['vercode'] == app['Current Version Code']: gotcur = True if not latest or int(build['vercode']) > int(latest['vercode']): latest = build if not gotcur: newbuild = latest.copy() if 'origlines' in newbuild: del newbuild['origlines'] newbuild['disable'] = False newbuild['vercode'] = app['Current Version Code'] newbuild['version'] = app['Current Version'] + suffix logging.info("...auto-generating build for " + newbuild['version']) commit = pattern.replace('%v', newbuild['version']) commit = commit.replace('%c', newbuild['vercode']) newbuild['commit'] = commit app['builds'].append(newbuild) name = common.getappname(app) ver = common.getcvname(app) commitmsg = "Update %s to %s" % (name, ver) else: logging.warn('Invalid auto update mode "' + mode + '" on ' + app['id']) if commitmsg: metafile = os.path.join('metadata', app['id'] + '.txt') metadata.write_metadata(metafile, app) if options.commit: logging.info("Commiting update for " + metafile) gitcmd = ["git", "commit", "-m", commitmsg] if 'auto_author' in config: gitcmd.extend(['--author', config['auto_author']]) gitcmd.extend(["--", metafile]) if subprocess.call(gitcmd) != 0: logging.error("Git commit failed") sys.exit(1)
def main(): global config, options # Parse command line... parser = OptionParser() parser.add_option("-u", "--url", default=None, help="Project URL to import from.") parser.add_option("-s", "--subdir", default=None, help="Path to main android project subdirectory, if not in root.") parser.add_option("-r", "--repo", default=None, help="Allows a different repo to be specified for a multi-repo google code project") parser.add_option("--rev", default=None, help="Allows a different revision (or git branch) to be specified for the initial import") (options, args) = parser.parse_args() config = common.read_config(options) if not options.url: print "Specify project url." sys.exit(1) url = options.url tmp_dir = 'tmp' if not os.path.isdir(tmp_dir): print "Creating temporary directory" os.makedirs(tmp_dir) # Get all apps... apps = metadata.read_metadata() # Figure out what kind of project it is... projecttype = None issuetracker = None license = None website = url #by default, we might override it if url.startswith('git://'): projecttype = 'git' repo = url repotype = 'git' sourcecode = "" website = "" elif url.startswith('https://github.com'): if url.endswith('/'): url = url[:-1] if url.endswith('.git'): print "A github URL should point to the project, not the git repo" sys.exit(1) projecttype = 'github' repo = url + '.git' repotype = 'git' sourcecode = url issuetracker = url + '/issues' elif url.startswith('https://gitorious.org/'): projecttype = 'gitorious' repo = 'https://git.gitorious.org/' + url[22:] + '.git' repotype = 'git' sourcecode = url elif url.startswith('https://bitbucket.org/'): if url.endswith('/'): url = url[:-1] projecttype = 'bitbucket' sourcecode = url + '/src' issuetracker = url + '/issues' # Figure out the repo type and adddress... repotype, repo = getrepofrompage(sourcecode) if not repotype: print "Unable to determine vcs type. " + repo sys.exit(1) elif url.startswith('http://code.google.com/p/'): if not url.endswith('/'): url += '/'; projecttype = 'googlecode' sourcecode = url + 'source/checkout' if options.repo: sourcecode += "?repo=" + options.repo issuetracker = url + 'issues/list' # Figure out the repo type and adddress... repotype, repo = getrepofrompage(sourcecode) if not repotype: print "Unable to determine vcs type. " + repo sys.exit(1) # Figure out the license... req = urllib.urlopen(url) if req.getcode() != 200: print 'Unable to find project page at ' + sourcecode + ' - return code ' + str(req.getcode()) sys.exit(1) page = req.read() index = page.find('Code license') if index == -1: print "Couldn't find license data" sys.exit(1) ltext = page[index:] lprefix = 'rel="nofollow">' index = ltext.find(lprefix) if index == -1: print "Couldn't find license text" sys.exit(1) ltext = ltext[index + len(lprefix):] index = ltext.find('<') if index == -1: print "License text not formatted as expected" sys.exit(1) ltext = ltext[:index] if ltext == 'GNU GPL v3': license = 'GPLv3' elif ltext == 'GNU GPL v2': license = 'GPLv2' elif ltext == 'Apache License 2.0': license = 'Apache2' elif ltext == 'MIT License': license = 'MIT' elif ltext == 'GNU Lesser GPL': license = 'LGPL' elif ltext == 'Mozilla Public License 1.1': license = 'MPL' elif ltext == 'New BSD License': license = 'NewBSD' else: print "License " + ltext + " is not recognised" sys.exit(1) if not projecttype: print "Unable to determine the project type." print "The URL you supplied was not in one of the supported formats. Please consult" print "the manual for a list of supported formats, and supply one of those." sys.exit(1) # Get a copy of the source so we can extract some info... print 'Getting source from ' + repotype + ' repo at ' + repo src_dir = os.path.join(tmp_dir, 'importer') if os.path.exists(src_dir): shutil.rmtree(src_dir) vcs = common.getvcs(repotype, repo, src_dir) vcs.gotorevision(options.rev) if options.subdir: root_dir = os.path.join(src_dir, options.subdir) else: root_dir = src_dir # Extract some information... paths = common.manifest_paths(root_dir, None) if paths: version, vercode, package = common.parse_androidmanifests(paths) if not package: print "Couldn't find package ID" sys.exit(1) if not version: print "WARNING: Couldn't find latest version name" if not vercode: print "WARNING: Couldn't find latest version code" else: spec = os.path.join(root_dir, 'buildozer.spec') if os.path.exists(spec): defaults = {'orientation': 'landscape', 'icon': '', 'permissions': '', 'android.api': "18"} bconfig = ConfigParser(defaults, allow_no_value=True) bconfig.read(spec) package = bconfig.get('app', 'package.domain') + '.' + bconfig.get('app', 'package.name') version = bconfig.get('app', 'version') vercode = None else: print "No android or kivy project could be found. Specify --subdir?" sys.exit(1) # Make sure it's actually new... for app in apps: if app['id'] == package: print "Package " + package + " already exists" sys.exit(1) # Construct the metadata... app = metadata.parse_metadata(None) app['id'] = package app['Web Site'] = website app['Source Code'] = sourcecode if issuetracker: app['Issue Tracker'] = issuetracker if license: app['License'] = license app['Repo Type'] = repotype app['Repo'] = repo app['Update Check Mode'] = "Tags" # Create a build line... build = {} build['version'] = version if version else '?' build['vercode'] = vercode if vercode else '?' build['commit'] = '?' build['disable'] = 'Generated by import.py - check/set version fields and commit id' if options.subdir: build['subdir'] = options.subdir if os.path.exists(os.path.join(root_dir, 'jni')): build['buildjni'] = 'yes' app['builds'].append(build) # Keep the repo directory to save bandwidth... if not os.path.exists('build'): os.mkdir('build') shutil.move(src_dir, os.path.join('build', package)) with open('build/.fdroidvcs-' + package, 'w') as f: f.write(repotype + ' ' + repo) metafile = os.path.join('metadata', package + '.txt') metadata.write_metadata(metafile, app) print "Wrote " + metafile
def main(): global config, options # Parse command line... parser = OptionParser() parser.add_option("-v", "--verbose", action="store_true", default=False, help="Spew out even more information than normal") parser.add_option("-q", "--quiet", action="store_true", default=False, help="Restrict output to warnings and errors") parser.add_option("-u", "--url", default=None, help="Project URL to import from.") parser.add_option("-s", "--subdir", default=None, help="Path to main android project subdirectory, if not in root.") parser.add_option("-r", "--repo", default=None, help="Allows a different repo to be specified for a multi-repo google code project") parser.add_option("--rev", default=None, help="Allows a different revision (or git branch) to be specified for the initial import") (options, args) = parser.parse_args() config = common.read_config(options) if not options.url: logging.error("Specify project url.") sys.exit(1) url = options.url tmp_dir = 'tmp' if not os.path.isdir(tmp_dir): logging.info("Creating temporary directory") os.makedirs(tmp_dir) # Get all apps... apps = metadata.read_metadata() # Figure out what kind of project it is... projecttype = None issuetracker = None license = None website = url # by default, we might override it if url.startswith('git://'): projecttype = 'git' repo = url repotype = 'git' sourcecode = "" website = "" elif url.startswith('https://github.com'): projecttype = 'github' repo = url repotype = 'git' sourcecode = url issuetracker = url + '/issues' elif url.startswith('https://gitlab.com/'): projecttype = 'gitlab' repo = url repotype = 'git' sourcecode = url issuetracker = url + '/issues' elif url.startswith('https://gitorious.org/'): projecttype = 'gitorious' repo = 'https://git.gitorious.org/' + url[22:] + '.git' repotype = 'git' sourcecode = url elif url.startswith('https://bitbucket.org/'): if url.endswith('/'): url = url[:-1] projecttype = 'bitbucket' sourcecode = url + '/src' issuetracker = url + '/issues' # Figure out the repo type and adddress... repotype, repo = getrepofrompage(sourcecode) if not repotype: logging.error("Unable to determine vcs type. " + repo) sys.exit(1) elif (url.startswith('http://code.google.com/p/') or url.startswith('https://code.google.com/p/')): if not url.endswith('/'): url += '/' projecttype = 'googlecode' sourcecode = url + 'source/checkout' if options.repo: sourcecode += "?repo=" + options.repo issuetracker = url + 'issues/list' # Figure out the repo type and adddress... repotype, repo = getrepofrompage(sourcecode) if not repotype: logging.error("Unable to determine vcs type. " + repo) sys.exit(1) # Figure out the license... req = urllib.urlopen(url) if req.getcode() != 200: logging.error('Unable to find project page at ' + sourcecode + ' - return code ' + str(req.getcode())) sys.exit(1) page = req.read() index = page.find('Code license') if index == -1: logging.error("Couldn't find license data") sys.exit(1) ltext = page[index:] lprefix = 'rel="nofollow">' index = ltext.find(lprefix) if index == -1: logging.error("Couldn't find license text") sys.exit(1) ltext = ltext[index + len(lprefix):] index = ltext.find('<') if index == -1: logging.error("License text not formatted as expected") sys.exit(1) ltext = ltext[:index] if ltext == 'GNU GPL v3': license = 'GPLv3' elif ltext == 'GNU GPL v2': license = 'GPLv2' elif ltext == 'Apache License 2.0': license = 'Apache2' elif ltext == 'MIT License': license = 'MIT' elif ltext == 'GNU Lesser GPL': license = 'LGPL' elif ltext == 'Mozilla Public License 1.1': license = 'MPL' elif ltext == 'New BSD License': license = 'NewBSD' else: logging.error("License " + ltext + " is not recognised") sys.exit(1) if not projecttype: logging.error("Unable to determine the project type.") logging.error("The URL you supplied was not in one of the supported formats. Please consult") logging.error("the manual for a list of supported formats, and supply one of those.") sys.exit(1) # Get a copy of the source so we can extract some info... logging.info('Getting source from ' + repotype + ' repo at ' + repo) src_dir = os.path.join(tmp_dir, 'importer') if os.path.exists(src_dir): shutil.rmtree(src_dir) vcs = common.getvcs(repotype, repo, src_dir) vcs.gotorevision(options.rev) if options.subdir: root_dir = os.path.join(src_dir, options.subdir) else: root_dir = src_dir # Extract some information... paths = common.manifest_paths(root_dir, None) if paths: version, vercode, package = common.parse_androidmanifests(paths) if not package: logging.error("Couldn't find package ID") sys.exit(1) if not version: logging.warn("Couldn't find latest version name") if not vercode: logging.warn("Couldn't find latest version code") else: spec = os.path.join(root_dir, 'buildozer.spec') if os.path.exists(spec): defaults = {'orientation': 'landscape', 'icon': '', 'permissions': '', 'android.api': "18"} bconfig = ConfigParser(defaults, allow_no_value=True) bconfig.read(spec) package = bconfig.get('app', 'package.domain') + '.' + bconfig.get('app', 'package.name') version = bconfig.get('app', 'version') vercode = None else: logging.error("No android or kivy project could be found. Specify --subdir?") sys.exit(1) # Make sure it's actually new... if package in apps: logging.error("Package " + package + " already exists") sys.exit(1) # Construct the metadata... app = metadata.parse_metadata(None)[1] app['Web Site'] = website app['Source Code'] = sourcecode if issuetracker: app['Issue Tracker'] = issuetracker if license: app['License'] = license app['Repo Type'] = repotype app['Repo'] = repo app['Update Check Mode'] = "Tags" # Create a build line... build = {} build['version'] = version or '?' build['vercode'] = vercode or '?' build['commit'] = '?' build['disable'] = 'Generated by import.py - check/set version fields and commit id' if options.subdir: build['subdir'] = options.subdir if os.path.exists(os.path.join(root_dir, 'jni')): build['buildjni'] = ['yes'] for flag, value in metadata.flag_defaults.iteritems(): if flag in build: continue build[flag] = value app['builds'].append(build) # Keep the repo directory to save bandwidth... if not os.path.exists('build'): os.mkdir('build') shutil.move(src_dir, os.path.join('build', package)) with open('build/.fdroidvcs-' + package, 'w') as f: f.write(repotype + ' ' + repo) metafile = os.path.join('metadata', package + '.txt') metadata.write_metadata(metafile, app) logging.info("Wrote " + metafile)
def main(): global config, options # Parse command line... parser = OptionParser() parser.add_option("-v", "--verbose", action="store_true", default=False, help="Spew out even more information than normal") parser.add_option("-p", "--package", default=None, help="Check only the specified package") parser.add_option("--auto", action="store_true", default=False, help="Process auto-updates") parser.add_option("--autoonly", action="store_true", default=False, help="Only process apps with auto-updates") parser.add_option("--commit", action="store_true", default=False, help="Commit changes") parser.add_option("--gplay", action="store_true", default=False, help="Only print differences with the Play Store") (options, args) = parser.parse_args() config = common.read_config(options) # Get all apps... apps = metadata.read_metadata(options.verbose) # Filter apps according to command-line options if options.package: apps = [app for app in apps if app['id'] == options.package] if len(apps) == 0: print "No such package" sys.exit(1) if options.gplay: for app in apps: version, reason = check_gplay(app) if version is None and options.verbose: if reason == '404': print "%s is not in the Play Store" % common.getappname(app) else: print "%s encountered a problem: %s" % common.getappname(app) if version is not None: stored = app['Current Version'] if LooseVersion(stored) < LooseVersion(version): print "%s has version %s on the Play Store, which is bigger than %s" % ( common.getappname(app), version, stored) elif options.verbose: print "%s has the same version %s on the Play Store" % ( common.getappname(app), version) return for app in apps: if options.autoonly and app['Auto Update Mode'] == 'None': if options.verbose: print "Nothing to do for %s..." % app['id'] continue print "Processing " + app['id'] + '...' writeit = False logmsg = None tag = None msg = None vercode = None mode = app['Update Check Mode'] if mode == 'Tags': (version, vercode, tag) = check_tags(app) elif mode == 'RepoManifest': (version, vercode) = check_repomanifest(app) elif mode.startswith('RepoManifest/'): tag = mode[13:] (version, vercode) = check_repomanifest(app, tag) elif mode == 'RepoTrunk': (version, vercode) = check_repotrunk(app) elif mode == 'HTTP': (version, vercode) = check_http(app) elif mode == 'Static': version = None msg = 'Checking disabled' elif mode == 'None': version = None msg = 'Checking disabled' else: version = None msg = 'Invalid update check method' if vercode and app['Vercode Operation']: op = app['Vercode Operation'].replace("%c", str(int(vercode))) vercode = str(eval(op)) updating = False if not version: print "...%s" % msg elif vercode == app['Current Version Code']: print "...up to date" else: app['Current Version'] = version app['Current Version Code'] = str(int(vercode)) updating = True writeit = True # Do the Auto Name thing as well as finding the CV real name if len(app["Repo Type"]) > 0: try: if app['Repo Type'] == 'srclib': app_dir = os.path.join('build', 'srclib', app['Repo']) else: app_dir = os.path.join('build/', app['id']) vcs = common.getvcs(app["Repo Type"], app["Repo"], app_dir) vcs.gotorevision(tag) flavour = None if len(app['builds']) > 0: if 'subdir' in app['builds'][-1]: app_dir = os.path.join(app_dir, app['builds'][-1]['subdir']) if 'gradle' in app['builds'][-1]: flavour = app['builds'][-1]['gradle'] new_name = common.fetch_real_name(app_dir, flavour) if new_name != app['Auto Name']: app['Auto Name'] = new_name if app['Current Version'].startswith('@string/'): cv = common.version_name(app['Current Version'], app_dir, flavour) if app['Current Version'] != cv: app['Current Version'] = cv writeit = True except Exception: print "ERROR: Auto Name or Current Version failed for %s due to exception: %s" % (app['id'], traceback.format_exc()) if updating: name = common.getappname(app) ver = common.getcvname(app) print '...updating to version %s' % ver logmsg = 'Update CV of %s to %s' % (name, ver) if options.auto: mode = app['Auto Update Mode'] if mode == 'None': pass elif mode.startswith('Version '): pattern = mode[8:] if pattern.startswith('+'): o = pattern.find(' ') suffix = pattern[1:o] pattern = pattern[o + 1:] else: suffix = '' gotcur = False latest = None for build in app['builds']: if build['vercode'] == app['Current Version Code']: gotcur = True if not latest or int(build['vercode']) > int(latest['vercode']): latest = build if not gotcur: newbuild = latest.copy() if 'origlines' in newbuild: del newbuild['origlines'] newbuild['vercode'] = app['Current Version Code'] newbuild['version'] = app['Current Version'] + suffix print "...auto-generating build for " + newbuild['version'] commit = pattern.replace('%v', newbuild['version']) commit = commit.replace('%c', newbuild['vercode']) newbuild['commit'] = commit app['builds'].append(newbuild) writeit = True name = common.getappname(app) ver = common.getcvname(app) logmsg = "Update %s to %s" % (name, ver) else: print 'Invalid auto update mode "' + mode + '"' if writeit: metafile = os.path.join('metadata', app['id'] + '.txt') metadata.write_metadata(metafile, app) if options.commit and logmsg: print "Commiting update for " + metafile gitcmd = ["git", "commit", "-m", logmsg] if 'auto_author' in config: gitcmd.extend(['--author', config['auto_author']]) gitcmd.extend(["--", metafile]) if subprocess.call(gitcmd) != 0: print "Git commit failed" sys.exit(1) print "Finished."
def main(): global config, options # Parse command line... parser = ArgumentParser() common.setup_global_opts(parser) parser.add_argument("-u", "--url", default=None, help="Project URL to import from.") parser.add_argument("-s", "--subdir", default=None, help="Path to main android project subdirectory, if not in root.") parser.add_argument("--rev", default=None, help="Allows a different revision (or git branch) to be specified for the initial import") options = parser.parse_args() config = common.read_config(options) apps = metadata.read_metadata() app = metadata.App() app.UpdateCheckMode = "Tags" root_dir = None build_dir = None if options.url: root_dir, build_dir = get_metadata_from_url(app, options.url) elif os.path.isdir('.git'): if options.url: app.WebSite = options.url root_dir = get_subdir(os.getcwd()) else: logging.error("Specify project url.") sys.exit(1) # Extract some information... paths = common.manifest_paths(root_dir, []) if paths: version, vercode, package = common.parse_androidmanifests(paths, app) if not package: logging.error("Couldn't find package ID") sys.exit(1) if not version: logging.warn("Couldn't find latest version name") if not vercode: logging.warn("Couldn't find latest version code") else: spec = os.path.join(root_dir, 'buildozer.spec') if os.path.exists(spec): defaults = {'orientation': 'landscape', 'icon': '', 'permissions': '', 'android.api': "18"} bconfig = ConfigParser(defaults, allow_no_value=True) bconfig.read(spec) package = bconfig.get('app', 'package.domain') + '.' + bconfig.get('app', 'package.name') version = bconfig.get('app', 'version') vercode = None else: logging.error("No android or kivy project could be found. Specify --subdir?") sys.exit(1) # Make sure it's actually new... if package in apps: logging.error("Package " + package + " already exists") sys.exit(1) # Create a build line... build = metadata.Build() build.version = version or '?' build.vercode = vercode or '?' build.commit = '?' build.disable = 'Generated by import.py - check/set version fields and commit id' if options.subdir: build.subdir = options.subdir if os.path.exists(os.path.join(root_dir, 'jni')): build.buildjni = ['yes'] app.builds.append(build) # Keep the repo directory to save bandwidth... if not os.path.exists('build'): os.mkdir('build') if build_dir is not None: shutil.move(build_dir, os.path.join('build', package)) with open('build/.fdroidvcs-' + package, 'w') as f: f.write(app.RepoType + ' ' + app.Repo) metadatapath = os.path.join('metadata', package + '.txt') with open(metadatapath, 'w') as f: metadata.write_metadata('txt', f, app) logging.info("Wrote " + metadatapath)
def main(): global config, options # Parse command line... parser = OptionParser() parser.add_option("-v", "--verbose", action="store_true", default=False, help="Spew out even more information than normal") parser.add_option("-q", "--quiet", action="store_true", default=False, help="Restrict output to warnings and errors") parser.add_option("-u", "--url", default=None, help="Project URL to import from.") parser.add_option("-s", "--subdir", default=None, help="Path to main android project subdirectory, if not in root.") parser.add_option("--rev", default=None, help="Allows a different revision (or git branch) to be specified for the initial import") (options, args) = parser.parse_args() config = common.read_config(options) if not options.url: logging.error("Specify project url.") sys.exit(1) url = options.url tmp_dir = 'tmp' if not os.path.isdir(tmp_dir): logging.info("Creating temporary directory") os.makedirs(tmp_dir) # Get all apps... apps = metadata.read_metadata() # Figure out what kind of project it is... projecttype = None issuetracker = None license = None website = url # by default, we might override it if url.startswith('git://'): projecttype = 'git' repo = url repotype = 'git' sourcecode = "" website = "" elif url.startswith('https://github.com'): projecttype = 'github' repo = url repotype = 'git' sourcecode = url issuetracker = url + '/issues' website = "" elif url.startswith('https://gitlab.com/'): projecttype = 'gitlab' repo = url repotype = 'git' sourcecode = url + '/tree/HEAD' issuetracker = url + '/issues' elif url.startswith('https://bitbucket.org/'): if url.endswith('/'): url = url[:-1] projecttype = 'bitbucket' sourcecode = url + '/src' issuetracker = url + '/issues' # Figure out the repo type and adddress... repotype, repo = getrepofrompage(sourcecode) if not repotype: logging.error("Unable to determine vcs type. " + repo) sys.exit(1) if not projecttype: logging.error("Unable to determine the project type.") logging.error("The URL you supplied was not in one of the supported formats. Please consult") logging.error("the manual for a list of supported formats, and supply one of those.") sys.exit(1) # Ensure we have a sensible-looking repo address at this point. If not, we # might have got a page format we weren't expecting. (Note that we # specifically don't want git@...) if ((repotype != 'bzr' and (not repo.startswith('http://') and not repo.startswith('https://') and not repo.startswith('git://'))) or ' ' in repo): logging.error("Repo address '{0}' does not seem to be valid".format(repo)) sys.exit(1) # Get a copy of the source so we can extract some info... logging.info('Getting source from ' + repotype + ' repo at ' + repo) src_dir = os.path.join(tmp_dir, 'importer') if os.path.exists(src_dir): shutil.rmtree(src_dir) vcs = common.getvcs(repotype, repo, src_dir) vcs.gotorevision(options.rev) if options.subdir: root_dir = os.path.join(src_dir, options.subdir) else: root_dir = src_dir # Extract some information... paths = common.manifest_paths(root_dir, []) if paths: version, vercode, package = common.parse_androidmanifests(paths) if not package: logging.error("Couldn't find package ID") sys.exit(1) if not version: logging.warn("Couldn't find latest version name") if not vercode: logging.warn("Couldn't find latest version code") else: spec = os.path.join(root_dir, 'buildozer.spec') if os.path.exists(spec): defaults = {'orientation': 'landscape', 'icon': '', 'permissions': '', 'android.api': "18"} bconfig = ConfigParser(defaults, allow_no_value=True) bconfig.read(spec) package = bconfig.get('app', 'package.domain') + '.' + bconfig.get('app', 'package.name') version = bconfig.get('app', 'version') vercode = None else: logging.error("No android or kivy project could be found. Specify --subdir?") sys.exit(1) # Make sure it's actually new... if package in apps: logging.error("Package " + package + " already exists") sys.exit(1) # Construct the metadata... app = metadata.parse_metadata(None)[1] app['Web Site'] = website app['Source Code'] = sourcecode if issuetracker: app['Issue Tracker'] = issuetracker if license: app['License'] = license app['Repo Type'] = repotype app['Repo'] = repo app['Update Check Mode'] = "Tags" # Create a build line... build = {} build['version'] = version or '?' build['vercode'] = vercode or '?' build['commit'] = '?' build['disable'] = 'Generated by import.py - check/set version fields and commit id' if options.subdir: build['subdir'] = options.subdir if os.path.exists(os.path.join(root_dir, 'jni')): build['buildjni'] = ['yes'] for flag, value in metadata.flag_defaults.iteritems(): if flag in build: continue build[flag] = value app['builds'].append(build) # Keep the repo directory to save bandwidth... if not os.path.exists('build'): os.mkdir('build') shutil.move(src_dir, os.path.join('build', package)) with open('build/.fdroidvcs-' + package, 'w') as f: f.write(repotype + ' ' + repo) metafile = os.path.join('metadata', package + '.txt') metadata.write_metadata(metafile, app) logging.info("Wrote " + metafile)
def main(): global config, options # Parse command line... parser = OptionParser() parser.add_option("-v", "--verbose", action="store_true", default=False, help="Spew out even more information than normal") parser.add_option("-q", "--quiet", action="store_true", default=False, help="Restrict output to warnings and errors") parser.add_option("-u", "--url", default=None, help="Project URL to import from.") parser.add_option( "-s", "--subdir", default=None, help="Path to main android project subdirectory, if not in root.") parser.add_option( "--rev", default=None, help= "Allows a different revision (or git branch) to be specified for the initial import" ) (options, args) = parser.parse_args() config = common.read_config(options) if not options.url: logging.error("Specify project url.") sys.exit(1) url = options.url tmp_dir = 'tmp' if not os.path.isdir(tmp_dir): logging.info("Creating temporary directory") os.makedirs(tmp_dir) # Get all apps... apps = metadata.read_metadata() # Figure out what kind of project it is... projecttype = None issuetracker = None license = None website = url # by default, we might override it if url.startswith('git://'): projecttype = 'git' repo = url repotype = 'git' sourcecode = "" website = "" elif url.startswith('https://github.com'): projecttype = 'github' repo = url repotype = 'git' sourcecode = url issuetracker = url + '/issues' website = "" elif url.startswith('https://gitlab.com/'): projecttype = 'gitlab' repo = url repotype = 'git' sourcecode = url + '/tree/HEAD' issuetracker = url + '/issues' elif url.startswith('https://bitbucket.org/'): if url.endswith('/'): url = url[:-1] projecttype = 'bitbucket' sourcecode = url + '/src' issuetracker = url + '/issues' # Figure out the repo type and adddress... repotype, repo = getrepofrompage(sourcecode) if not repotype: logging.error("Unable to determine vcs type. " + repo) sys.exit(1) if not projecttype: logging.error("Unable to determine the project type.") logging.error( "The URL you supplied was not in one of the supported formats. Please consult" ) logging.error( "the manual for a list of supported formats, and supply one of those." ) sys.exit(1) # Ensure we have a sensible-looking repo address at this point. If not, we # might have got a page format we weren't expecting. (Note that we # specifically don't want git@...) if ((repotype != 'bzr' and (not repo.startswith('http://') and not repo.startswith('https://') and not repo.startswith('git://'))) or ' ' in repo): logging.error( "Repo address '{0}' does not seem to be valid".format(repo)) sys.exit(1) # Get a copy of the source so we can extract some info... logging.info('Getting source from ' + repotype + ' repo at ' + repo) src_dir = os.path.join(tmp_dir, 'importer') if os.path.exists(src_dir): shutil.rmtree(src_dir) vcs = common.getvcs(repotype, repo, src_dir) vcs.gotorevision(options.rev) if options.subdir: root_dir = os.path.join(src_dir, options.subdir) else: root_dir = src_dir # Extract some information... paths = common.manifest_paths(root_dir, []) if paths: version, vercode, package = common.parse_androidmanifests(paths) if not package: logging.error("Couldn't find package ID") sys.exit(1) if not version: logging.warn("Couldn't find latest version name") if not vercode: logging.warn("Couldn't find latest version code") else: spec = os.path.join(root_dir, 'buildozer.spec') if os.path.exists(spec): defaults = { 'orientation': 'landscape', 'icon': '', 'permissions': '', 'android.api': "18" } bconfig = ConfigParser(defaults, allow_no_value=True) bconfig.read(spec) package = bconfig.get('app', 'package.domain') + '.' + bconfig.get( 'app', 'package.name') version = bconfig.get('app', 'version') vercode = None else: logging.error( "No android or kivy project could be found. Specify --subdir?") sys.exit(1) # Make sure it's actually new... if package in apps: logging.error("Package " + package + " already exists") sys.exit(1) # Construct the metadata... app = metadata.parse_metadata(None)[1] app['Web Site'] = website app['Source Code'] = sourcecode if issuetracker: app['Issue Tracker'] = issuetracker if license: app['License'] = license app['Repo Type'] = repotype app['Repo'] = repo app['Update Check Mode'] = "Tags" # Create a build line... build = {} build['version'] = version or '?' build['vercode'] = vercode or '?' build['commit'] = '?' build[ 'disable'] = 'Generated by import.py - check/set version fields and commit id' if options.subdir: build['subdir'] = options.subdir if os.path.exists(os.path.join(root_dir, 'jni')): build['buildjni'] = ['yes'] for flag, value in metadata.flag_defaults.iteritems(): if flag in build: continue build[flag] = value app['builds'].append(build) # Keep the repo directory to save bandwidth... if not os.path.exists('build'): os.mkdir('build') shutil.move(src_dir, os.path.join('build', package)) with open('build/.fdroidvcs-' + package, 'w') as f: f.write(repotype + ' ' + repo) metafile = os.path.join('metadata', package + '.txt') metadata.write_metadata(metafile, app) logging.info("Wrote " + metafile)