From 99b5d5e3875d766ba762d7dcea16bf5032177e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 20 Dec 2013 09:42:10 +0100 Subject: [PATCH] Get rid of more unnecessary finds --- fdroidserver/build.py | 6 +++--- fdroidserver/checkupdates.py | 8 +++++--- fdroidserver/update.py | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/fdroidserver/build.py b/fdroidserver/build.py index e7fe5591..f134178d 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -94,11 +94,11 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force): p = subprocess.Popen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'list', '--details'], cwd='builder', stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output = p.communicate()[0] - if output.find('fdroidclean') != -1: + if 'fdroidclean' in output: if options.verbose: print "...snapshot exists - resetting build server to clean state" retcode, output = vagrant(['status'], cwd='builder') - if output.find('running') != -1: + if 'running' in output: if options.verbose: print "...suspending" vagrant(['suspend'], cwd='builder') @@ -186,7 +186,7 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force): p = subprocess.Popen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'list', '--details'], cwd='builder', stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output = p.communicate()[0] - if output.find('fdroidclean') == -1: + if 'fdroidclean' not in output: raise BuildException("Failed to take snapshot.") try: diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index 3b59ef4e..dc88c2dc 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -31,6 +31,7 @@ from distutils.version import LooseVersion import common, metadata from common import BuildException from common import VCSException +from metadata import MetaDataException # Check for a new version by looking at a document retrieved via HTTP. @@ -413,9 +414,10 @@ def main(): elif mode.startswith('Version '): pattern = mode[8:] if pattern.startswith('+'): - o = pattern.find(' ') - suffix = pattern[1:o] - pattern = pattern[o + 1:] + try: + suffix, pattern = pattern.split(' ', 1) + except ValueError: + raise MetaDataException("Invalid AUM at: " + line) else: suffix = '' gotcur = False diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 93e1cccd..7d761212 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -307,7 +307,7 @@ def scan_apks(apps, apkcache, repodir, knownapks): for apkfile in glob.glob(os.path.join(repodir, '*.apk')): apkfilename = apkfile[len(repodir) + 1:] - if apkfilename.find(' ') != -1: + if ' ' in apkfilename: print "No spaces in APK filenames!" sys.exit(1)