import time
import operator
import Queue
-import threading
import logging
import hashlib
import socket
from zipfile import ZipFile
import metadata
+from fdroidserver.asynchronousfilereader import AsynchronousFileReader
+
XMLElementTree.register_namespace('android', 'http://schemas.android.com/apk/res/android')
'r9b': None,
'r10e': "$ANDROID_NDK",
},
- 'build_tools': "23.0.0",
+ 'build_tools': "23.0.1",
'ant': "ant",
'mvn3': "mvn",
'gradle': 'gradle',
}
+def setup_global_opts(parser):
+ parser.add_argument("-v", "--verbose", action="store_true", default=False,
+ help="Spew out even more information than normal")
+ parser.add_argument("-q", "--quiet", action="store_true", default=False,
+ help="Restrict output to warnings and errors")
+
+
def fill_config_defaults(thisconfig):
for k, v in default_config.items():
if k not in thisconfig:
return apps
-def has_extension(filename, extension):
- name, ext = os.path.splitext(filename)
- ext = ext.lower()[1:]
- return ext == extension
+def get_extension(filename):
+ _, ext = os.path.splitext(filename)
+ if not ext:
+ return ''
+ return ext.lower()[1:]
+
+
+def has_extension(filename, ext):
+ return ext == get_extension(filename)
+
apk_regex = None
raise VCSException('gettags not supported for this vcs type')
rtags = []
for tag in self._gettags():
- if re.match('[-A-Za-z0-9_. ]+$', tag):
+ if re.match('[-A-Za-z0-9_. /]+$', tag):
rtags.append(tag)
return rtags
vcsearch_g = re.compile(r'.*versionCode *=* *["\']*([0-9]+)["\']*').search
vnsearch_g = re.compile(r'.*versionName *=* *(["\'])((?:(?=(\\?))\3.)*?)\1.*').search
- psearch_g = re.compile(r'.*packageName *=* *["\']([^"]+)["\'].*').search
+ psearch_g = re.compile(r'.*(packageName|applicationId) *=* *["\']([^"]+)["\'].*').search
ignoresearch = re.compile(ignoreversions).search if ignoreversions else None
gradle = has_extension(path, 'gradle')
version = None
vercode = None
- # Remember package name, may be defined separately from version+vercode
- package = max_package
+ package = None
if gradle:
for line in file(path):
+ # Grab first occurence of each to avoid running into
+ # alternative flavours and builds.
if not package:
matches = psearch_g(line)
if matches:
- package = matches.group(1)
+ package = matches.group(2)
if not version:
matches = vnsearch_g(line)
if matches:
if string_is_integer(a):
vercode = a
+ # Remember package name, may be defined separately from version+vercode
+ if package is None:
+ package = max_package
+
logging.debug("..got package={0}, version={1}, vercode={2}"
.format(package, version, vercode))
return False
-class AsynchronousFileReader(threading.Thread):
-
- '''
- Helper class to implement asynchronous reading of a file
- in a separate thread. Pushes read lines on a queue to
- be consumed in another thread.
- '''
-
- def __init__(self, fd, queue):
- assert isinstance(queue, Queue.Queue)
- assert callable(fd.readline)
- threading.Thread.__init__(self)
- self._fd = fd
- self._queue = queue
-
- def run(self):
- '''The body of the tread: read lines and put them on the queue.'''
- for line in iter(self._fd.readline, ''):
- self._queue.put(line)
-
- def eof(self):
- '''Check whether there is no more content to expect.'''
- return not self.is_alive() and self._queue.empty()
-
-
class PopenResult:
returncode = None
output = ''
stdout_queue = Queue.Queue()
stdout_reader = AsynchronousFileReader(p.stdout, stdout_queue)
- stdout_reader.start()
# Check the queue for output (until there is no more to get)
while not stdout_reader.eof():