summaryrefslogtreecommitdiffstats
path: root/utils/common
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2019-11-17 11:55:46 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2020-06-13 20:11:48 +0200
commit440791105a22c7c42ef0c57ef44e4e6f01fa00e9 (patch)
treeb9dd1ac3ebd8ee047042564053ca1ea7210dc936 /utils/common
parentaefbc13e19af974156e76f0b8184dad41982ebfb (diff)
downloadrockbox-440791105a22c7c42ef0c57ef44e4e6f01fa00e9.tar.gz
rockbox-440791105a22c7c42ef0c57ef44e4e6f01fa00e9.tar.bz2
rockbox-440791105a22c7c42ef0c57ef44e4e6f01fa00e9.zip
deploy: Fix various style issues.
Fix various pylint issues and some python3 compatibility. Change-Id: I2c35ccc5ad2d0902c229f9de57912cf6d5a83ece
Diffstat (limited to 'utils/common')
-rwxr-xr-xutils/common/deploy-rbutil.py50
-rwxr-xr-xutils/common/deploy-themeeditor.py10
-rwxr-xr-xutils/common/deploy.py149
-rwxr-xr-xutils/common/gitscraper.py58
-rwxr-xr-xutils/common/tarball.py2
5 files changed, 139 insertions, 130 deletions
diff --git a/utils/common/deploy-rbutil.py b/utils/common/deploy-rbutil.py
index 5085f18efb..2cdbdb52b5 100755
--- a/utils/common/deploy-rbutil.py
+++ b/utils/common/deploy-rbutil.py
@@ -22,30 +22,30 @@ deploy.program = "RockboxUtility"
deploy.project = "rbutil/rbutilqt/rbutilqt.pro"
deploy.svnserver = "svn://svn.rockbox.org/rockbox/"
deploy.svnpaths = \
- [ "rbutil/",
- "tools/ucl",
- "tools/rbspeex",
- "utils/imxtools",
- "utils/nwztools",
- "lib/rbcodec/codecs/libspeex",
- "docs/COPYING",
- "docs/gpl-2.0.html",
- "docs/logo/rockbox-clef.svg",
- "docs/CREDITS",
- "tools/iriver.c",
- "tools/Makefile",
- "tools/mkboot.h",
- "tools/voicefont.c",
- "tools/VOICE_PAUSE.wav",
- "tools/voice-corrections.txt",
- "tools/wavtrim.h",
- "tools/iriver.h",
- "tools/mkboot.c",
- "tools/telechips.c",
- "tools/telechips.h",
- "tools/voicefont.h",
- "tools/wavtrim.c",
- "tools/sapi_voice.vbs" ]
+ ["rbutil/",
+ "tools/ucl",
+ "tools/rbspeex",
+ "utils/imxtools",
+ "utils/nwztools",
+ "lib/rbcodec/codecs/libspeex",
+ "docs/COPYING",
+ "docs/gpl-2.0.html",
+ "docs/logo/rockbox-clef.svg",
+ "docs/CREDITS",
+ "tools/iriver.c",
+ "tools/Makefile",
+ "tools/mkboot.h",
+ "tools/voicefont.c",
+ "tools/VOICE_PAUSE.wav",
+ "tools/voice-corrections.txt",
+ "tools/wavtrim.h",
+ "tools/iriver.h",
+ "tools/mkboot.c",
+ "tools/telechips.c",
+ "tools/telechips.h",
+ "tools/voicefont.h",
+ "tools/wavtrim.c",
+ "tools/sapi_voice.vbs"]
deploy.useupx = False
deploy.bundlecopy = {
"icons/rbutilqt.icns" : "Contents/Resources/",
@@ -77,7 +77,7 @@ deploy.make = {
# all files of the program. Will get put into an archive after building
# (zip on w32, tar.bz2 on Linux). Does not apply on Mac which uses dmg.
# progexe will get added automatically.
-deploy.programfiles = [ ]
+deploy.programfiles = list()
deploy.nsisscript = ""
deploy.deploy()
diff --git a/utils/common/deploy-themeeditor.py b/utils/common/deploy-themeeditor.py
index 8b66e5aef4..0b72d43985 100755
--- a/utils/common/deploy-themeeditor.py
+++ b/utils/common/deploy-themeeditor.py
@@ -22,13 +22,13 @@ deploy.program = "rbthemeeditor"
deploy.project = "utils/themeeditor/themeeditor.pro"
deploy.svnserver = "svn://svn.rockbox.org/rockbox/"
deploy.svnpaths = \
- [ "utils/themeeditor/",
- "lib/skin_parser/",
- "docs/COPYING" ]
+ ["utils/themeeditor/",
+ "lib/skin_parser/",
+ "docs/COPYING"]
deploy.useupx = False
deploy.bundlecopy = {
"resources/windowicon.icns" : "Contents/Resources/",
- "Info.plist" : "Contents/"
+ "Info.plist" : "Contents/"
}
deploy.progexe = {
"win32" : "release/rbthemeeditor.exe",
@@ -52,7 +52,7 @@ deploy.make = {
# all files of the program. Will get put into an archive after building
# (zip on w32, tar.bz2 on Linux). Does not apply on Mac which uses dmg.
# progexe will get added automatically.
-deploy.programfiles = [ ]
+deploy.programfiles = list()
deploy.nsisscript = "utils/themeeditor/themeeditor.nsi"
deploy.deploy()
diff --git a/utils/common/deploy.py b/utils/common/deploy.py
index 571424756b..e0bb7029b8 100755
--- a/utils/common/deploy.py
+++ b/utils/common/deploy.py
@@ -43,21 +43,21 @@ import getopt
import time
import hashlib
import tempfile
-import gitscraper
from datetime import datetime
+import gitscraper
# modules that are not part of python itself.
cpus = 1
try:
import multiprocessing
cpus = multiprocessing.cpu_count()
- print "Info: %s cores found." % cpus
+ print("Info: %s cores found." % cpus)
except ImportError:
- print "Warning: multiprocessing module not found. Assuming 1 core."
+ print("Warning: multiprocessing module not found. Assuming 1 core.")
# == Global stuff ==
# DLL files to ignore when searching for required DLL files.
-systemdlls = [
+SYSTEMDLLS = [
'advapi32.dll',
'comdlg32.dll',
'crypt32.dll',
@@ -94,23 +94,23 @@ gitrepo = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
# == Functions ==
def usage(myself):
- print "Usage: %s [options]" % myself
- print " -q, --qmake=<qmake> path to qmake"
- print " -p, --project=<pro> path to .pro file for building with local tree"
- print " -t, --tag=<tag> use specified tag from svn"
- print " -a, --add=<file> add file to build folder before building"
- print " -s, --source-only only create source archive"
- print " -b, --binary-only only create binary archive"
+ print("Usage: %s [options]" % myself)
+ print(" -q, --qmake=<qmake> path to qmake")
+ print(" -p, --project=<pro> path to .pro file for building with local tree")
+ print(" -t, --tag=<tag> use specified tag from svn")
+ print(" -a, --add=<file> add file to build folder before building")
+ print(" -s, --source-only only create source archive")
+ print(" -b, --binary-only only create binary archive")
if nsisscript != "":
- print " -n, --makensis=<file> path to makensis for building Windows setup program."
+ print(" -n, --makensis=<file> path to makensis for building Windows setup program.")
if sys.platform != "darwin":
- print " -d, --dynamic link dynamically instead of static"
+ print(" -d, --dynamic link dynamically instead of static")
if sys.platform != "win32":
- print " -x, --cross= prefix to cross compile for win32"
- print " -k, --keep-temp keep temporary folder on build failure"
- print " -h, --help this help"
- print " If neither a project file nor tag is specified trunk will get downloaded"
- print " from svn."
+ print(" -x, --cross= prefix to cross compile for win32")
+ print(" -k, --keep-temp keep temporary folder on build failure")
+ print(" -h, --help this help")
+ print(" If neither a project file nor tag is specified trunk will get downloaded")
+ print(" from svn.")
def which(executable):
@@ -119,7 +119,7 @@ def which(executable):
fullpath = p + "/" + executable
if os.path.exists(fullpath):
return fullpath
- print "which: could not find " + executable
+ print("which: could not find " + executable)
return ""
@@ -152,7 +152,7 @@ def findversion(versionfile):
def findqt(cross=""):
'''Search for Qt4 installation. Return path to qmake.'''
- print "Searching for Qt"
+ print("Searching for Qt")
bins = [cross + "qmake", cross + "qmake-qt4"]
for binary in bins:
try:
@@ -162,7 +162,7 @@ def findqt(cross=""):
if not result == "":
return result
except:
- print sys.exc_value
+ print(sys.exc_value)
return ""
@@ -172,27 +172,27 @@ def checkqt(qmakebin):
result = ""
# check if binary exists
if not os.path.exists(qmakebin):
- print "Specified qmake path does not exist!"
+ print("Specified qmake path does not exist!")
return result
# check version
- output = subprocess.Popen([qmakebin, "-version"], stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ output = subprocess.Popen(
+ [qmakebin, "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
cmdout = output.communicate()
# don't check the qmake return code here, Qt3 doesn't return 0 on -version.
for ou in cmdout:
r = re.compile("Qt[^0-9]+([0-9\.]+[a-z]*)")
m = re.search(r, ou)
if not m == None:
- print "Qt found: %s" % m.group(1)
+ print("Qt found: %s" % m.group(1))
s = re.compile("[45]\..*")
n = re.search(s, m.group(1))
- if not n == None:
+ if n is not None:
result = qmakebin
return result
def qmake(qmake, projfile, platform=sys.platform, wd=".", static=True, cross=""):
- print "Running qmake in %s..." % wd
+ print("Running qmake in %s..." % wd)
command = [qmake, "-config", "release", "-config", "noccache"]
if static == True:
command.extend(["-config", "-static"])
@@ -206,14 +206,14 @@ def qmake(qmake, projfile, platform=sys.platform, wd=".", static=True, cross="")
output = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=wd)
output.communicate()
if not output.returncode == 0:
- print "qmake returned an error!"
+ print("qmake returned an error!")
return -1
return 0
def build(wd=".", platform=sys.platform, cross=""):
# make
- print "Building ..."
+ print("Building ...")
# use the current platforms make here, cross compiling uses the native make.
command = [make[sys.platform]]
if cpus > 1:
@@ -228,36 +228,36 @@ def build(wd=".", platform=sys.platform, cross=""):
sys.stdout.write("\n")
sys.stdout.flush()
if not output.returncode == 0:
- print "Build failed!"
+ print("Build failed!")
return -1
break
if platform != "darwin":
# strip. OS X handles this via macdeployqt.
- print "Stripping binary."
+ print("Stripping binary.")
output = subprocess.Popen([cross + "strip", progexe[platform]], \
stdout=subprocess.PIPE, cwd=wd)
output.communicate()
if not output.returncode == 0:
- print "Stripping failed!"
+ print("Stripping failed!")
return -1
return 0
def upxfile(wd=".", platform=sys.platform):
# run upx on binary
- print "UPX'ing binary ..."
+ print("UPX'ing binary ...")
output = subprocess.Popen(["upx", progexe[platform]], \
stdout=subprocess.PIPE, cwd=wd)
output.communicate()
if not output.returncode == 0:
- print "UPX'ing failed!"
+ print("UPX'ing failed!")
return -1
return 0
def runnsis(versionstring, nsis, script, srcfolder):
# run script through nsis to create installer.
- print "Running NSIS ..."
+ print("Running NSIS ...")
# Assume the generated installer gets placed in the same folder the nsi
# script lives in. This seems to be a valid assumption unless the nsi
@@ -276,7 +276,7 @@ def runnsis(versionstring, nsis, script, srcfolder):
stdout=subprocess.PIPE)
output.communicate()
if not output.returncode == 0:
- print "NSIS failed!"
+ print("NSIS failed!")
return -1
setupfile = program + "-" + versionstring + "-setup.exe"
# find output filename in nsis script file
@@ -285,7 +285,7 @@ def runnsis(versionstring, nsis, script, srcfolder):
if re.match(r'^[^;]*OutFile\s+', line) != None:
nsissetup = re.sub(r'^[^;]*OutFile\s+"(.+)"', r'\1', line).rstrip()
if nsissetup == "":
- print "Could not retrieve output file name!"
+ print("Could not retrieve output file name!")
return -1
shutil.copy(srcfolder + "/" + os.path.dirname(script) + "/" + nsissetup, \
setupfile)
@@ -330,29 +330,29 @@ def finddlls(program, extrapaths=[], cross=""):
# find DLLs in extrapaths and PATH environment variable.
dllpaths = []
for file in dlls:
- if file in systemdlls:
- print "System DLL: " + file
+ if file in SYSTEMDLLS:
+ print("System DLL: " + file)
continue
dllpath = ""
for path in extrapaths:
if os.path.exists(path + "/" + file):
dllpath = re.sub(r"\\", r"/", path + "/" + file)
- print file + ": found at " + dllpath
+ print(file + ": found at " + dllpath)
dllpaths.append(dllpath)
break
if dllpath == "":
try:
dllpath = re.sub(r"\\", r"/", which(file))
- print file + ": found at " + dllpath
+ print(file + ": found at " + dllpath)
dllpaths.append(dllpath)
except:
- print "MISSING DLL: " + file
+ print("MISSING DLL: " + file)
return dllpaths
def zipball(programfiles, versionstring, buildfolder, platform=sys.platform):
'''package created binary'''
- print "Creating binary zipball."
+ print("Creating binary zipball.")
archivebase = program + "-" + versionstring
outfolder = buildfolder + "/" + archivebase
archivename = archivebase + ".zip"
@@ -379,7 +379,7 @@ def zipball(programfiles, versionstring, buildfolder, platform=sys.platform):
def tarball(programfiles, versionstring, buildfolder):
'''package created binary'''
- print "Creating binary tarball."
+ print("Creating binary tarball.")
archivebase = program + "-" + versionstring
outfolder = buildfolder + "/" + archivebase
archivename = archivebase + ".tar.bz2"
@@ -404,7 +404,7 @@ def macdeploy(versionstring, buildfolder, platform=sys.platform):
# workaround to Qt issues when building out-of-tree. Copy files into bundle.
sourcebase = buildfolder + re.sub('[^/]+.pro$', '', project) + "/"
- print sourcebase
+ print(sourcebase)
for src in bundlecopy:
shutil.copy(sourcebase + src, appbundle + "/" + bundlecopy[src])
# end of Qt workaround
@@ -413,7 +413,7 @@ def macdeploy(versionstring, buildfolder, platform=sys.platform):
stdout=subprocess.PIPE, cwd=buildfolder)
output.communicate()
if not output.returncode == 0:
- print "macdeployqt failed!"
+ print("macdeployqt failed!")
return -1
# copy dmg to output folder
shutil.copy(buildfolder + "/" + program + ".dmg", dmgfile)
@@ -440,32 +440,33 @@ def filestats(filename):
if not os.path.exists(filename):
return
st = os.stat(filename)
- print filename, "\n", "-" * len(filename)
- print "Size: %i bytes" % st.st_size
+ print(filename, "\n", "-" * len(filename))
+ print("Size: %i bytes" % st.st_size)
h = filehashes(filename)
- print "md5sum: %s" % h[0]
- print "sha1sum: %s" % h[1]
- print "-" * len(filename), "\n"
+ print("md5sum: %s" % h[0])
+ print("sha1sum: %s" % h[1])
+ print("-" * len(filename), "\n")
def tempclean(workfolder, nopro):
if nopro == True:
- print "Cleaning up working folder %s" % workfolder
+ print("Cleaning up working folder %s" % workfolder)
shutil.rmtree(workfolder)
else:
- print "Project file specified or cleanup disabled!"
- print "Temporary files kept at %s" % workfolder
+ print("Project file specified or cleanup disabled!")
+ print("Temporary files kept at %s" % workfolder)
def deploy():
startup = time.time()
try:
- opts, args = getopt.getopt(sys.argv[1:], "q:p:t:a:n:sbdkx:i:h",
+ opts, args = getopt.getopt(
+ sys.argv[1:], "q:p:t:a:n:sbdkx:i:h",
["qmake=", "project=", "tag=", "add=", "makensis=", "source-only",
"binary-only", "dynamic", "keep-temp", "cross=", "buildid=", "help"])
- except getopt.GetoptError, err:
- print str(err)
+ except getopt.GetoptError as err:
+ print(str(err))
usage(sys.argv[0])
sys.exit(1)
qt = ""
@@ -516,17 +517,17 @@ def deploy():
sys.exit(0)
if source == False and binary == False:
- print "Building build neither source nor binary means nothing to do. Exiting."
+ print("Building build neither source nor binary means nothing to do. Exiting.")
sys.exit(1)
- print "Building " + progexe[platform] + " for " + platform
+ print("Building " + progexe[platform] + " for " + platform)
# search for qmake
if qt == "":
qm = findqt(cross)
else:
qm = checkqt(qt)
if qm == "":
- print "ERROR: No suitable Qt installation found."
+ print("ERROR: No suitable Qt installation found.")
sys.exit(1)
# create working folder. Use current directory if -p option used.
@@ -552,7 +553,7 @@ def deploy():
archivename = program + "-" + str(revision) + versionextra + "-src.tar.bz2"
ver = str(revision)
os.mkdir(sourcefolder)
- print "Version: %s" % revision
+ print("Version: %s" % revision)
else:
workfolder = "."
sourcefolder = "."
@@ -561,12 +562,12 @@ def deploy():
if proj == "":
proj = sourcefolder + project
# get sources and pack source tarball
- if not getsources(treehash, svnpaths, sourcefolder) == 0:
+ if getsources(treehash, svnpaths, sourcefolder) != 0:
tempclean(workfolder, cleanup and not keeptemp)
sys.exit(1)
# replace version strings.
- print "Updating version information in sources"
+ print("Updating version information in sources")
for f in regreplace:
infile = open(sourcefolder + "/" + f, "r")
incontents = infile.readlines()
@@ -590,7 +591,7 @@ def deploy():
outfile.close()
if source == True:
- print "Creating source tarball %s\n" % archivename
+ print("Creating source tarball %s\n" % archivename)
tf = tarfile.open(archivename, mode='w:bz2')
tf.add(sourcefolder, os.path.basename(re.subn('/$', '', sourcefolder)[0]))
tf.close()
@@ -607,7 +608,7 @@ def deploy():
# check project file
if not os.path.exists(proj):
- print "ERROR: path to project file wrong."
+ print("ERROR: path to project file wrong.")
sys.exit(1)
# copy specified (--add) files to working folder
@@ -615,8 +616,8 @@ def deploy():
shutil.copy(f, sourcefolder)
buildstart = time.time()
header = "Building %s %s" % (program, ver)
- print header
- print len(header) * "="
+ print(header)
+ print(len(header) * "=")
# build it.
if not qmake(qm, proj, platform, sourcefolder, static, cross) == 0:
@@ -649,8 +650,8 @@ def deploy():
if platform == "linux2":
for p in progfiles:
prog = sourcefolder + "/" + p
- output = subprocess.Popen(["file", prog],
- stdout=subprocess.PIPE)
+ output = subprocess.Popen(
+ ["file", prog], stdout=subprocess.PIPE)
res = output.communicate()
if re.findall("ELF 64-bit", res[0]):
ver += "-64bit"
@@ -663,7 +664,7 @@ def deploy():
# display summary
headline = "Build Summary for %s" % program
- print "\n", headline, "\n", "=" * len(headline)
+ print("\n", headline, "\n", "=" * len(headline))
if not archivename == "":
filestats(archivename)
filestats(archive)
@@ -672,10 +673,10 @@ def deploy():
dursecs = (int)(duration % 60)
buildmins = (int)(buildtime / 60)
buildsecs = (int)(buildtime % 60)
- print "Overall time %smin %ssec, building took %smin %ssec." % \
- (durmins, dursecs, buildmins, buildsecs)
+ print("Overall time %smin %ssec, building took %smin %ssec." % \
+ (durmins, dursecs, buildmins, buildsecs))
if __name__ == "__main__":
- print "You cannot run this module directly!"
- print "Set required environment and call deploy()."
+ print("You cannot run this module directly!")
+ print("Set required environment and call deploy().")
diff --git a/utils/common/gitscraper.py b/utils/common/gitscraper.py
index 86d6a980cd..496d32bce3 100755
--- a/utils/common/gitscraper.py
+++ b/utils/common/gitscraper.py
@@ -42,10 +42,11 @@ def get_refs(repo):
@return Dict matching hashes to each ref.
'''
print("Getting list of refs")
- output = subprocess.Popen(["git", "show-ref", "--abbrev"],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
+ output = subprocess.Popen(
+ ["git", "show-ref", "--abbrev"],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
cmdout = output.communicate()
- refs = {}
+ refs = dict()
if len(cmdout[1]) > 0:
print("An error occured!\n")
@@ -53,7 +54,7 @@ def get_refs(repo):
return refs
for line in cmdout:
- regex = re.findall(b'([a-f0-9]+)\s+(\S+)', line)
+ regex = re.findall(b'([a-f0-9]+)\\s+(\\S+)', line)
for r in regex:
# ref is the key, hash its value.
refs[r[1].decode()] = r[0].decode()
@@ -61,7 +62,7 @@ def get_refs(repo):
return refs
-def get_lstree(repo, start, filterlist=[]):
+def get_lstree(repo, start, filterlist=None):
'''Get recursive list of tree objects for a given tree.
@param repo Path to repository root.
@param start Hash identifying the tree.
@@ -69,10 +70,13 @@ def get_lstree(repo, start, filterlist=[]):
An empty list will retrieve all paths.
@return Dict mapping filename to blob hash
'''
- output = subprocess.Popen(["git", "ls-tree", "-r", start],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
+ if filterlist is None:
+ filterlist = list()
+ output = subprocess.Popen(
+ ["git", "ls-tree", "-r", start],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
cmdout = output.communicate()
- objects = {}
+ objects = dict()
if len(cmdout[1]) > 0:
print("An error occured!\n")
@@ -80,8 +84,8 @@ def get_lstree(repo, start, filterlist=[]):
return objects
for line in cmdout[0].decode().split('\n'):
- regex = re.findall(b'([0-9]+)\s+([a-z]+)\s+([0-9a-f]+)\s+(.*)',
- line.encode())
+ regex = re.findall(b'([0-9]+)\\s+([a-z]+)\\s+([0-9a-f]+)\\s+(.*)',
+ line.encode())
for rf in regex:
# filter
add = False
@@ -107,8 +111,8 @@ def get_file_timestamp(repo, tree, filename):
@return Timestamp as string.
'''
output = subprocess.Popen(
- ["git", "log", "--format=%ai", "-n", "1", tree, filename],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
+ ["git", "log", "--format=%ai", "-n", "1", tree, filename],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
cmdout = output.communicate()
return cmdout[0].decode().rstrip()
@@ -121,8 +125,9 @@ def get_object(repo, blob, destfile):
@param destfile filename for blob output.
@return True if file was successfully written, False on error.
'''
- output = subprocess.Popen(["git", "cat-file", "-p", blob],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
+ output = subprocess.Popen(
+ ["git", "cat-file", "-p", blob],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
cmdout = output.communicate()
# make sure output path exists
if len(cmdout[1]) > 0:
@@ -143,8 +148,9 @@ def describe_treehash(repo, treehash):
@param treehash Hash identifying the tree / commit to describe.
@return Description string.
'''
- output = subprocess.Popen(["git", "describe", treehash],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
+ output = subprocess.Popen(
+ ["git", "describe", treehash],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
cmdout = output.communicate()
if len(cmdout[1]) > 0:
print("An error occured!\n")
@@ -153,7 +159,7 @@ def describe_treehash(repo, treehash):
return cmdout[0].rstrip()
-def scrape_files(repo, treehash, filelist, dest="", timestamp_files=[]):
+def scrape_files(repo, treehash, filelist, dest=None, timestamp_files=None):
'''Scrape list of files from repository.
@param repo Path to repository root.
@param treehash Hash identifying the tree.
@@ -167,7 +173,9 @@ def scrape_files(repo, treehash, filelist, dest="", timestamp_files=[]):
'''
print("Scraping files from repository")
- if dest == "":
+ if timestamp_files is None:
+ timestamp_files = list()
+ if dest is None:
dest = tempfile.mkdtemp()
treeobjects = get_lstree(repo, treehash, filelist)
timestamps = {}
@@ -180,8 +188,8 @@ def scrape_files(repo, treehash, filelist, dest="", timestamp_files=[]):
return [dest, timestamps]
-def archive_files(repo, treehash, filelist, basename, tmpfolder="",
- archive="tbz"):
+def archive_files(repo, treehash, filelist, basename, tmpfolder=None,
+ archive="tbz"):
'''Archive list of files into tarball.
@param repo Path to repository root.
@param treehash Hash identifying the tree.
@@ -197,20 +205,20 @@ def archive_files(repo, treehash, filelist, basename, tmpfolder="",
@return Output filename.
'''
- if tmpfolder == "":
+ if tmpfolder is None:
temp_remove = True
tmpfolder = tempfile.mkdtemp()
else:
temp_remove = False
- workfolder = scrape_files(repo, treehash, filelist,
- os.path.join(tmpfolder, basename))[0]
+ workfolder = scrape_files(
+ repo, treehash, filelist, os.path.join(tmpfolder, basename))[0]
if basename is "":
return ""
print("Archiving files from repository")
if archive == "7z":
outfile = basename + ".7z"
- output = subprocess.Popen(["7z", "a",
- os.path.join(os.getcwd(), basename + ".7z"), basename],
+ output = subprocess.Popen(
+ ["7z", "a", os.path.join(os.getcwd(), basename + ".7z"), basename],
cwd=tmpfolder, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output.communicate()
elif archive == "tbz":
diff --git a/utils/common/tarball.py b/utils/common/tarball.py
index 2e32776702..3fda206002 100755
--- a/utils/common/tarball.py
+++ b/utils/common/tarball.py
@@ -1,8 +1,8 @@
#!/usr/bin/python
-import gitscraper
import os
import sys
+import gitscraper
if len(sys.argv) < 2:
print("Usage: %s <version|hash>" % sys.argv[0])