chiark / gitweb /
Resolved some unpleasant global-scope usage and related issues
authorCiaran Gultnieks <ciaran@ciarang.com>
Sun, 26 Feb 2012 17:14:15 +0000 (17:14 +0000)
committerCiaran Gultnieks <ciaran@ciarang.com>
Sun, 26 Feb 2012 17:14:15 +0000 (17:14 +0000)
build.py
checkupdates.py
import.py
publish.py
scanner.py
stats.py
update.py

index d1ad62c332f7ce263a02ac39a241c963f9d8fc74..dfd9d7a04fbbe6082dbb97e3675e492cb5dbaa22 100755 (executable)
--- a/build.py
+++ b/build.py
@@ -118,7 +118,7 @@ def build_server(app, thisbuild, build_dir, output_dir):
         raise BuildException("Failed to destroy")
 
 
-def build_local(app, thisbuild, build_dir, output_dir):
+def build_local(app, thisbuild, vcs, build_dir, output_dir, extlib_dir, tmp_dir, install):
     """Do a build locally."""
 
     # Prepare the source code...
@@ -156,8 +156,6 @@ def build_local(app, thisbuild, build_dir, output_dir):
         if p.returncode != 0:
             print output
             raise BuildException("NDK build failed for %s:%s" % (app['id'], thisbuild['version']))
-        elif options.verbose:
-            print output
 
     # Build the release...
     if thisbuild.has_key('maven'):
@@ -165,7 +163,7 @@ def build_local(app, thisbuild, build_dir, output_dir):
             '-Dandroid.sdk.path=' + sdk_path],
             cwd=root_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     else:
-        if options.install:
+        if install:
             antcommands = ['debug',' install']
         elif thisbuild.has_key('antcommand'):
             antcommands = [thisbuild['antcommand']]
@@ -176,8 +174,6 @@ def build_local(app, thisbuild, build_dir, output_dir):
     output, error = p.communicate()
     if p.returncode != 0:
         raise BuildException("Build failed for %s:%s" % (app['id'], thisbuild['version']), output.strip(), error.strip())
-    elif options.verbose:
-        print output
     print "Build successful"
 
     # Find the apk name in the output...
@@ -241,6 +237,8 @@ def build_local(app, thisbuild, build_dir, output_dir):
 
     # Copy the unsigned apk to our destination directory for further
     # processing (by publish.py)...
+    dest = os.path.join(output_dir, app['id'] + '_' +
+            thisbuild['vercode'] + '.apk')
     shutil.copyfile(src, dest)
 
     # Move the source tarball into the output directory...
@@ -250,7 +248,8 @@ def build_local(app, thisbuild, build_dir, output_dir):
             os.path.join(output_dir, tarfilename))
 
 
-def trybuild(app, thisbuild, build_dir, output_dir, repo_dir, vcs, test):
+def trybuild(app, thisbuild, build_dir, output_dir, extlib_dir, tmp_dir,
+        repo_dir, vcs, test, server, install):
     """
     Build a particular version of an application, if it needs building.
 
@@ -268,16 +267,12 @@ def trybuild(app, thisbuild, build_dir, output_dir, repo_dir, vcs, test):
     if thisbuild['commit'].startswith('!'):
         return False
 
-    if options.verbose:
-        mstart = '.. building version '
-    else:
-        mstart = 'Building version '
-    print mstart + thisbuild['version'] + ' of ' + app['id']
+    print "Building version " + thisbuild['version'] + ' of ' + app['id']
 
-    if options.server:
+    if server:
         build_server(app, thisbuild, build_dir, output_dir)
     else:
-        build_local(app, thisbuild, build_dir, output_dir)
+        build_local(app, thisbuild, vcs, build_dir, output_dir, extlib_dir, tmp_dir, install)
     return True
 
 
@@ -313,6 +308,9 @@ def parse_commandline():
 
     # The --install option implies --test and --force...
     if options.install:
+        if options.server:
+            print "Can't install when building on a build server."
+            sys.exit(1)
         options.force = True
         options.test = True
 
@@ -322,7 +320,7 @@ def parse_commandline():
 def main():
 
     # Read configuration...
-    execfile('config.py')
+    execfile('config.py', globals())
     options, args = parse_commandline()
 
     # Get all apps...
@@ -382,8 +380,9 @@ def main():
 
         for thisbuild in app['builds']:
             try:
-                if trybuild(app, thisbuild, build_dir, output_dir, repo_dir,
-                        vcs, options.test):
+                if trybuild(app, thisbuild, build_dir, output_dir, extlib_dir,
+                        tmp_dir, repo_dir, vcs, options.test, options.server,
+                        options.install):
                     build_succeeded.append(app)
             except BuildException as be:
                 if options.stop:
index b679d6f8958a928fbae21fed9a5c04449addeb8b..bd0fffbf728ee58340f3cc21428eac7136cb29b4 100755 (executable)
@@ -46,6 +46,7 @@ def check_market(app):
 
     m = re.search('<dd itemprop="softwareVersion">([^>]+)</dd>', page)
     if m:
+        html_parser = HTMLParser.HTMLParser()
         version = html_parser.unescape(m.group(1))
 
     if version == 'Varies with device':
@@ -66,7 +67,7 @@ def check_market(app):
 def main():
 
     #Read configuration...
-    execfile('config.py')
+    execfile('config.py', globals())
 
     # Parse command line...
     parser = OptionParser()
@@ -79,8 +80,6 @@ def main():
     # Get all apps...
     apps = common.read_metadata(options.verbose)
 
-    html_parser = HTMLParser.HTMLParser()
-
     for app in apps:
 
         if options.package and options.package != app['id']:
index 3d794cb8e7a8be8d2600bc3943c6bb9192b8438f..0e7307c98f471a715583545bca939c6c919b8568 100755 (executable)
--- a/import.py
+++ b/import.py
@@ -28,11 +28,7 @@ from optparse import OptionParser
 def main():
 
     # Read configuration...
-    repo_name = None
-    repo_description = None
-    repo_icon = None
-    repo_url = None
-    execfile('config.py')
+    execfile('config.py', globals())
 
     import common
 
index c5610ffe80de795a41177d8375b6ce25eb853490..be92c3ed17952ab5293f3cdaec82e1e5ee65b351 100755 (executable)
@@ -34,7 +34,7 @@ from common import BuildException
 def main():
 
     #Read configuration...
-    execfile('config.py')
+    execfile('config.py', globals())
 
     # Parse command line...
     parser = OptionParser()
index ad4e20fba71bcdb69c0c52662e774cbde4918c00..382b19827e1ec199ed05e621c2697954b77b5324 100755 (executable)
@@ -34,7 +34,7 @@ from common import VCSException
 def main():
 
     # Read configuration...
-    execfile('config.py')
+    execfile('config.py', globals())
 
 
     # Parse command line...
index a6f9816929dd53b3c71e8fcb9485016721cf8c99..5492096e56a8c77d4e1d95b8cda50723e08f7c30 100755 (executable)
--- a/stats.py
+++ b/stats.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 #
-# updatestats.py - part of the FDroid server tools
+# stats.py - part of the FDroid server tools
 # Copyright (C) 2010-12, Ciaran Gultnieks, ciaran@ciarang.com
 #
 # This program is free software: you can redistribute it and/or modify
@@ -33,7 +33,7 @@ import common
 def main():
 
     # Read configuration...
-    execfile('config.py')
+    execfile('config.py', globals())
 
     # Parse command line...
     parser = OptionParser()
index f378db7caf77c7aba3e268b4b77ad1aed8b74945..b03258ba133550819ca509ddc810433caca788ca 100755 (executable)
--- a/update.py
+++ b/update.py
@@ -32,11 +32,7 @@ import time
 def main():
 
     # Read configuration...
-    repo_name = None
-    repo_description = None
-    repo_icon = None
-    repo_url = None
-    execfile('config.py')
+    execfile('config.py', globals())
 
     import common
 
@@ -69,13 +65,6 @@ def main():
 
     warnings = 0
 
-    # Make sure we have the repository description...
-    if (repo_url is None or repo_name is None or
-            repo_icon is None or repo_description is None):
-        print "Repository description fields are required in config.py"
-        print "See config.sample.py for details"
-        sys.exit(1)
-
     # Get all apps...
     apps = common.read_metadata(verbose=options.verbose)