diff --git a/fdroidserver/build.py b/fdroidserver/build.py
index dbae089a..be934108 100644
--- a/fdroidserver/build.py
+++ b/fdroidserver/build.py
@@ -34,6 +34,7 @@ from distutils.version import LooseVersion
import logging
import common
+import net
import metadata
import scanner
from common import FDroidException, BuildException, VCSException, FDroidPopen, SdkToolsPopen
@@ -1093,7 +1094,7 @@ def main():
logging.info("...retrieving " + url)
of = "{0}_{1}.apk.binary".format(app['id'], thisbuild['vercode'])
of = os.path.join(output_dir, of)
- common.download_file(url, local_filename=of)
+ net.download_file(url, local_filename=of)
build_succeeded.append(app)
wikilog = "Build succeeded"
diff --git a/fdroidserver/common.py b/fdroidserver/common.py
index 6347d24f..d3c7f176 100644
--- a/fdroidserver/common.py
+++ b/fdroidserver/common.py
@@ -17,12 +17,14 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
+# common.py is imported by all modules, so do not import third-party
+# libraries here as they will become a requirement for all commands.
+
import os
import sys
import re
import shutil
import glob
-import requests
import stat
import subprocess
import time
@@ -1916,20 +1918,6 @@ def string_is_integer(string):
return False
-def download_file(url, local_filename=None, dldir='tmp'):
- filename = url.split('/')[-1]
- if local_filename is None:
- local_filename = os.path.join(dldir, filename)
- # the stream=True parameter keeps memory usage low
- r = requests.get(url, stream=True)
- with open(local_filename, 'wb') as f:
- for chunk in r.iter_content(chunk_size=1024):
- if chunk: # filter out keep-alive new chunks
- f.write(chunk)
- f.flush()
- return local_filename
-
-
def get_per_app_repos():
'''per-app repos are dirs named with the packageName of a single app'''
diff --git a/fdroidserver/net.py b/fdroidserver/net.py
new file mode 100644
index 00000000..42d7567d
--- /dev/null
+++ b/fdroidserver/net.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+#
+# net.py - part of the FDroid server tools
+# Copyright (C) 2015 Hans-Christoph Steiner
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+
+import os
+
+import requests
+
+
+def download_file(url, local_filename=None, dldir='tmp'):
+ filename = url.split('/')[-1]
+ if local_filename is None:
+ local_filename = os.path.join(dldir, filename)
+ # the stream=True parameter keeps memory usage low
+ r = requests.get(url, stream=True)
+ with open(local_filename, 'wb') as f:
+ for chunk in r.iter_content(chunk_size=1024):
+ if chunk: # filter out keep-alive new chunks
+ f.write(chunk)
+ f.flush()
+ return local_filename
diff --git a/fdroidserver/verify.py b/fdroidserver/verify.py
index fd0464eb..b751c499 100644
--- a/fdroidserver/verify.py
+++ b/fdroidserver/verify.py
@@ -24,6 +24,7 @@ from optparse import OptionParser
import logging
import common
+import net
from common import FDroidException
options = None
@@ -78,7 +79,7 @@ def main():
os.remove(remoteapk)
url = 'https://f-droid.org/repo/' + apkfilename
logging.info("...retrieving " + url)
- common.download_file(url, dldir=tmp_dir)
+ net.download_file(url, dldir=tmp_dir)
compare_result = common.compare_apks(
os.path.join(unsigned_dir, apkfilename),