A modern, network-enabled music player platform built on Rockbox technology. rockboxd.tsiry-sandratraina.com
rust deno navidrome airplay libadwaita zig mpris snapcast mpd rockbox audio subsonic
2

Configure Feed

Select the types of activity you want to include in your feed.

deploy: Fix various style issues.

Fix various pylint issues and some python3 compatibility.

Change-Id: I2c35ccc5ad2d0902c229f9de57912cf6d5a83ece

+139 -130
+25 -25
utils/common/deploy-rbutil.py
··· 22 22 deploy.project = "rbutil/rbutilqt/rbutilqt.pro" 23 23 deploy.svnserver = "svn://svn.rockbox.org/rockbox/" 24 24 deploy.svnpaths = \ 25 - [ "rbutil/", 26 - "tools/ucl", 27 - "tools/rbspeex", 28 - "utils/imxtools", 29 - "utils/nwztools", 30 - "lib/rbcodec/codecs/libspeex", 31 - "docs/COPYING", 32 - "docs/gpl-2.0.html", 33 - "docs/logo/rockbox-clef.svg", 34 - "docs/CREDITS", 35 - "tools/iriver.c", 36 - "tools/Makefile", 37 - "tools/mkboot.h", 38 - "tools/voicefont.c", 39 - "tools/VOICE_PAUSE.wav", 40 - "tools/voice-corrections.txt", 41 - "tools/wavtrim.h", 42 - "tools/iriver.h", 43 - "tools/mkboot.c", 44 - "tools/telechips.c", 45 - "tools/telechips.h", 46 - "tools/voicefont.h", 47 - "tools/wavtrim.c", 48 - "tools/sapi_voice.vbs" ] 25 + ["rbutil/", 26 + "tools/ucl", 27 + "tools/rbspeex", 28 + "utils/imxtools", 29 + "utils/nwztools", 30 + "lib/rbcodec/codecs/libspeex", 31 + "docs/COPYING", 32 + "docs/gpl-2.0.html", 33 + "docs/logo/rockbox-clef.svg", 34 + "docs/CREDITS", 35 + "tools/iriver.c", 36 + "tools/Makefile", 37 + "tools/mkboot.h", 38 + "tools/voicefont.c", 39 + "tools/VOICE_PAUSE.wav", 40 + "tools/voice-corrections.txt", 41 + "tools/wavtrim.h", 42 + "tools/iriver.h", 43 + "tools/mkboot.c", 44 + "tools/telechips.c", 45 + "tools/telechips.h", 46 + "tools/voicefont.h", 47 + "tools/wavtrim.c", 48 + "tools/sapi_voice.vbs"] 49 49 deploy.useupx = False 50 50 deploy.bundlecopy = { 51 51 "icons/rbutilqt.icns" : "Contents/Resources/", ··· 77 77 # all files of the program. Will get put into an archive after building 78 78 # (zip on w32, tar.bz2 on Linux). Does not apply on Mac which uses dmg. 79 79 # progexe will get added automatically. 80 - deploy.programfiles = [ ] 80 + deploy.programfiles = list() 81 81 deploy.nsisscript = "" 82 82 83 83 deploy.deploy()
+5 -5
utils/common/deploy-themeeditor.py
··· 22 22 deploy.project = "utils/themeeditor/themeeditor.pro" 23 23 deploy.svnserver = "svn://svn.rockbox.org/rockbox/" 24 24 deploy.svnpaths = \ 25 - [ "utils/themeeditor/", 26 - "lib/skin_parser/", 27 - "docs/COPYING" ] 25 + ["utils/themeeditor/", 26 + "lib/skin_parser/", 27 + "docs/COPYING"] 28 28 deploy.useupx = False 29 29 deploy.bundlecopy = { 30 30 "resources/windowicon.icns" : "Contents/Resources/", 31 - "Info.plist" : "Contents/" 31 + "Info.plist" : "Contents/" 32 32 } 33 33 deploy.progexe = { 34 34 "win32" : "release/rbthemeeditor.exe", ··· 52 52 # all files of the program. Will get put into an archive after building 53 53 # (zip on w32, tar.bz2 on Linux). Does not apply on Mac which uses dmg. 54 54 # progexe will get added automatically. 55 - deploy.programfiles = [ ] 55 + deploy.programfiles = list() 56 56 deploy.nsisscript = "utils/themeeditor/themeeditor.nsi" 57 57 58 58 deploy.deploy()
+75 -74
utils/common/deploy.py
··· 43 43 import time 44 44 import hashlib 45 45 import tempfile 46 - import gitscraper 47 46 from datetime import datetime 47 + import gitscraper 48 48 49 49 # modules that are not part of python itself. 50 50 cpus = 1 51 51 try: 52 52 import multiprocessing 53 53 cpus = multiprocessing.cpu_count() 54 - print "Info: %s cores found." % cpus 54 + print("Info: %s cores found." % cpus) 55 55 except ImportError: 56 - print "Warning: multiprocessing module not found. Assuming 1 core." 56 + print("Warning: multiprocessing module not found. Assuming 1 core.") 57 57 58 58 # == Global stuff == 59 59 # DLL files to ignore when searching for required DLL files. 60 - systemdlls = [ 60 + SYSTEMDLLS = [ 61 61 'advapi32.dll', 62 62 'comdlg32.dll', 63 63 'crypt32.dll', ··· 94 94 95 95 # == Functions == 96 96 def usage(myself): 97 - print "Usage: %s [options]" % myself 98 - print " -q, --qmake=<qmake> path to qmake" 99 - print " -p, --project=<pro> path to .pro file for building with local tree" 100 - print " -t, --tag=<tag> use specified tag from svn" 101 - print " -a, --add=<file> add file to build folder before building" 102 - print " -s, --source-only only create source archive" 103 - print " -b, --binary-only only create binary archive" 97 + print("Usage: %s [options]" % myself) 98 + print(" -q, --qmake=<qmake> path to qmake") 99 + print(" -p, --project=<pro> path to .pro file for building with local tree") 100 + print(" -t, --tag=<tag> use specified tag from svn") 101 + print(" -a, --add=<file> add file to build folder before building") 102 + print(" -s, --source-only only create source archive") 103 + print(" -b, --binary-only only create binary archive") 104 104 if nsisscript != "": 105 - print " -n, --makensis=<file> path to makensis for building Windows setup program." 105 + print(" -n, --makensis=<file> path to makensis for building Windows setup program.") 106 106 if sys.platform != "darwin": 107 - print " -d, --dynamic link dynamically instead of static" 107 + print(" -d, --dynamic link dynamically instead of static") 108 108 if sys.platform != "win32": 109 - print " -x, --cross= prefix to cross compile for win32" 110 - print " -k, --keep-temp keep temporary folder on build failure" 111 - print " -h, --help this help" 112 - print " If neither a project file nor tag is specified trunk will get downloaded" 113 - print " from svn." 109 + print(" -x, --cross= prefix to cross compile for win32") 110 + print(" -k, --keep-temp keep temporary folder on build failure") 111 + print(" -h, --help this help") 112 + print(" If neither a project file nor tag is specified trunk will get downloaded") 113 + print(" from svn.") 114 114 115 115 116 116 def which(executable): ··· 119 119 fullpath = p + "/" + executable 120 120 if os.path.exists(fullpath): 121 121 return fullpath 122 - print "which: could not find " + executable 122 + print("which: could not find " + executable) 123 123 return "" 124 124 125 125 ··· 152 152 153 153 def findqt(cross=""): 154 154 '''Search for Qt4 installation. Return path to qmake.''' 155 - print "Searching for Qt" 155 + print("Searching for Qt") 156 156 bins = [cross + "qmake", cross + "qmake-qt4"] 157 157 for binary in bins: 158 158 try: ··· 162 162 if not result == "": 163 163 return result 164 164 except: 165 - print sys.exc_value 165 + print(sys.exc_value) 166 166 167 167 return "" 168 168 ··· 172 172 result = "" 173 173 # check if binary exists 174 174 if not os.path.exists(qmakebin): 175 - print "Specified qmake path does not exist!" 175 + print("Specified qmake path does not exist!") 176 176 return result 177 177 # check version 178 - output = subprocess.Popen([qmakebin, "-version"], stdout=subprocess.PIPE, 179 - stderr=subprocess.PIPE) 178 + output = subprocess.Popen( 179 + [qmakebin, "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) 180 180 cmdout = output.communicate() 181 181 # don't check the qmake return code here, Qt3 doesn't return 0 on -version. 182 182 for ou in cmdout: 183 183 r = re.compile("Qt[^0-9]+([0-9\.]+[a-z]*)") 184 184 m = re.search(r, ou) 185 185 if not m == None: 186 - print "Qt found: %s" % m.group(1) 186 + print("Qt found: %s" % m.group(1)) 187 187 s = re.compile("[45]\..*") 188 188 n = re.search(s, m.group(1)) 189 - if not n == None: 189 + if n is not None: 190 190 result = qmakebin 191 191 return result 192 192 193 193 194 194 def qmake(qmake, projfile, platform=sys.platform, wd=".", static=True, cross=""): 195 - print "Running qmake in %s..." % wd 195 + print("Running qmake in %s..." % wd) 196 196 command = [qmake, "-config", "release", "-config", "noccache"] 197 197 if static == True: 198 198 command.extend(["-config", "-static"]) ··· 206 206 output = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=wd) 207 207 output.communicate() 208 208 if not output.returncode == 0: 209 - print "qmake returned an error!" 209 + print("qmake returned an error!") 210 210 return -1 211 211 return 0 212 212 213 213 214 214 def build(wd=".", platform=sys.platform, cross=""): 215 215 # make 216 - print "Building ..." 216 + print("Building ...") 217 217 # use the current platforms make here, cross compiling uses the native make. 218 218 command = [make[sys.platform]] 219 219 if cpus > 1: ··· 228 228 sys.stdout.write("\n") 229 229 sys.stdout.flush() 230 230 if not output.returncode == 0: 231 - print "Build failed!" 231 + print("Build failed!") 232 232 return -1 233 233 break 234 234 if platform != "darwin": 235 235 # strip. OS X handles this via macdeployqt. 236 - print "Stripping binary." 236 + print("Stripping binary.") 237 237 output = subprocess.Popen([cross + "strip", progexe[platform]], \ 238 238 stdout=subprocess.PIPE, cwd=wd) 239 239 output.communicate() 240 240 if not output.returncode == 0: 241 - print "Stripping failed!" 241 + print("Stripping failed!") 242 242 return -1 243 243 return 0 244 244 245 245 246 246 def upxfile(wd=".", platform=sys.platform): 247 247 # run upx on binary 248 - print "UPX'ing binary ..." 248 + print("UPX'ing binary ...") 249 249 output = subprocess.Popen(["upx", progexe[platform]], \ 250 250 stdout=subprocess.PIPE, cwd=wd) 251 251 output.communicate() 252 252 if not output.returncode == 0: 253 - print "UPX'ing failed!" 253 + print("UPX'ing failed!") 254 254 return -1 255 255 return 0 256 256 257 257 258 258 def runnsis(versionstring, nsis, script, srcfolder): 259 259 # run script through nsis to create installer. 260 - print "Running NSIS ..." 260 + print("Running NSIS ...") 261 261 262 262 # Assume the generated installer gets placed in the same folder the nsi 263 263 # script lives in. This seems to be a valid assumption unless the nsi ··· 276 276 stdout=subprocess.PIPE) 277 277 output.communicate() 278 278 if not output.returncode == 0: 279 - print "NSIS failed!" 279 + print("NSIS failed!") 280 280 return -1 281 281 setupfile = program + "-" + versionstring + "-setup.exe" 282 282 # find output filename in nsis script file ··· 285 285 if re.match(r'^[^;]*OutFile\s+', line) != None: 286 286 nsissetup = re.sub(r'^[^;]*OutFile\s+"(.+)"', r'\1', line).rstrip() 287 287 if nsissetup == "": 288 - print "Could not retrieve output file name!" 288 + print("Could not retrieve output file name!") 289 289 return -1 290 290 shutil.copy(srcfolder + "/" + os.path.dirname(script) + "/" + nsissetup, \ 291 291 setupfile) ··· 330 330 # find DLLs in extrapaths and PATH environment variable. 331 331 dllpaths = [] 332 332 for file in dlls: 333 - if file in systemdlls: 334 - print "System DLL: " + file 333 + if file in SYSTEMDLLS: 334 + print("System DLL: " + file) 335 335 continue 336 336 dllpath = "" 337 337 for path in extrapaths: 338 338 if os.path.exists(path + "/" + file): 339 339 dllpath = re.sub(r"\\", r"/", path + "/" + file) 340 - print file + ": found at " + dllpath 340 + print(file + ": found at " + dllpath) 341 341 dllpaths.append(dllpath) 342 342 break 343 343 if dllpath == "": 344 344 try: 345 345 dllpath = re.sub(r"\\", r"/", which(file)) 346 - print file + ": found at " + dllpath 346 + print(file + ": found at " + dllpath) 347 347 dllpaths.append(dllpath) 348 348 except: 349 - print "MISSING DLL: " + file 349 + print("MISSING DLL: " + file) 350 350 return dllpaths 351 351 352 352 353 353 def zipball(programfiles, versionstring, buildfolder, platform=sys.platform): 354 354 '''package created binary''' 355 - print "Creating binary zipball." 355 + print("Creating binary zipball.") 356 356 archivebase = program + "-" + versionstring 357 357 outfolder = buildfolder + "/" + archivebase 358 358 archivename = archivebase + ".zip" ··· 379 379 380 380 def tarball(programfiles, versionstring, buildfolder): 381 381 '''package created binary''' 382 - print "Creating binary tarball." 382 + print("Creating binary tarball.") 383 383 archivebase = program + "-" + versionstring 384 384 outfolder = buildfolder + "/" + archivebase 385 385 archivename = archivebase + ".tar.bz2" ··· 404 404 405 405 # workaround to Qt issues when building out-of-tree. Copy files into bundle. 406 406 sourcebase = buildfolder + re.sub('[^/]+.pro$', '', project) + "/" 407 - print sourcebase 407 + print(sourcebase) 408 408 for src in bundlecopy: 409 409 shutil.copy(sourcebase + src, appbundle + "/" + bundlecopy[src]) 410 410 # end of Qt workaround ··· 413 413 stdout=subprocess.PIPE, cwd=buildfolder) 414 414 output.communicate() 415 415 if not output.returncode == 0: 416 - print "macdeployqt failed!" 416 + print("macdeployqt failed!") 417 417 return -1 418 418 # copy dmg to output folder 419 419 shutil.copy(buildfolder + "/" + program + ".dmg", dmgfile) ··· 440 440 if not os.path.exists(filename): 441 441 return 442 442 st = os.stat(filename) 443 - print filename, "\n", "-" * len(filename) 444 - print "Size: %i bytes" % st.st_size 443 + print(filename, "\n", "-" * len(filename)) 444 + print("Size: %i bytes" % st.st_size) 445 445 h = filehashes(filename) 446 - print "md5sum: %s" % h[0] 447 - print "sha1sum: %s" % h[1] 448 - print "-" * len(filename), "\n" 446 + print("md5sum: %s" % h[0]) 447 + print("sha1sum: %s" % h[1]) 448 + print("-" * len(filename), "\n") 449 449 450 450 451 451 def tempclean(workfolder, nopro): 452 452 if nopro == True: 453 - print "Cleaning up working folder %s" % workfolder 453 + print("Cleaning up working folder %s" % workfolder) 454 454 shutil.rmtree(workfolder) 455 455 else: 456 - print "Project file specified or cleanup disabled!" 457 - print "Temporary files kept at %s" % workfolder 456 + print("Project file specified or cleanup disabled!") 457 + print("Temporary files kept at %s" % workfolder) 458 458 459 459 460 460 def deploy(): 461 461 startup = time.time() 462 462 463 463 try: 464 - opts, args = getopt.getopt(sys.argv[1:], "q:p:t:a:n:sbdkx:i:h", 464 + opts, args = getopt.getopt( 465 + sys.argv[1:], "q:p:t:a:n:sbdkx:i:h", 465 466 ["qmake=", "project=", "tag=", "add=", "makensis=", "source-only", 466 467 "binary-only", "dynamic", "keep-temp", "cross=", "buildid=", "help"]) 467 - except getopt.GetoptError, err: 468 - print str(err) 468 + except getopt.GetoptError as err: 469 + print(str(err)) 469 470 usage(sys.argv[0]) 470 471 sys.exit(1) 471 472 qt = "" ··· 516 517 sys.exit(0) 517 518 518 519 if source == False and binary == False: 519 - print "Building build neither source nor binary means nothing to do. Exiting." 520 + print("Building build neither source nor binary means nothing to do. Exiting.") 520 521 sys.exit(1) 521 522 522 - print "Building " + progexe[platform] + " for " + platform 523 + print("Building " + progexe[platform] + " for " + platform) 523 524 # search for qmake 524 525 if qt == "": 525 526 qm = findqt(cross) 526 527 else: 527 528 qm = checkqt(qt) 528 529 if qm == "": 529 - print "ERROR: No suitable Qt installation found." 530 + print("ERROR: No suitable Qt installation found.") 530 531 sys.exit(1) 531 532 532 533 # create working folder. Use current directory if -p option used. ··· 552 553 archivename = program + "-" + str(revision) + versionextra + "-src.tar.bz2" 553 554 ver = str(revision) 554 555 os.mkdir(sourcefolder) 555 - print "Version: %s" % revision 556 + print("Version: %s" % revision) 556 557 else: 557 558 workfolder = "." 558 559 sourcefolder = "." ··· 561 562 if proj == "": 562 563 proj = sourcefolder + project 563 564 # get sources and pack source tarball 564 - if not getsources(treehash, svnpaths, sourcefolder) == 0: 565 + if getsources(treehash, svnpaths, sourcefolder) != 0: 565 566 tempclean(workfolder, cleanup and not keeptemp) 566 567 sys.exit(1) 567 568 568 569 # replace version strings. 569 - print "Updating version information in sources" 570 + print("Updating version information in sources") 570 571 for f in regreplace: 571 572 infile = open(sourcefolder + "/" + f, "r") 572 573 incontents = infile.readlines() ··· 590 591 outfile.close() 591 592 592 593 if source == True: 593 - print "Creating source tarball %s\n" % archivename 594 + print("Creating source tarball %s\n" % archivename) 594 595 tf = tarfile.open(archivename, mode='w:bz2') 595 596 tf.add(sourcefolder, os.path.basename(re.subn('/$', '', sourcefolder)[0])) 596 597 tf.close() ··· 607 608 608 609 # check project file 609 610 if not os.path.exists(proj): 610 - print "ERROR: path to project file wrong." 611 + print("ERROR: path to project file wrong.") 611 612 sys.exit(1) 612 613 613 614 # copy specified (--add) files to working folder ··· 615 616 shutil.copy(f, sourcefolder) 616 617 buildstart = time.time() 617 618 header = "Building %s %s" % (program, ver) 618 - print header 619 - print len(header) * "=" 619 + print(header) 620 + print(len(header) * "=") 620 621 621 622 # build it. 622 623 if not qmake(qm, proj, platform, sourcefolder, static, cross) == 0: ··· 649 650 if platform == "linux2": 650 651 for p in progfiles: 651 652 prog = sourcefolder + "/" + p 652 - output = subprocess.Popen(["file", prog], 653 - stdout=subprocess.PIPE) 653 + output = subprocess.Popen( 654 + ["file", prog], stdout=subprocess.PIPE) 654 655 res = output.communicate() 655 656 if re.findall("ELF 64-bit", res[0]): 656 657 ver += "-64bit" ··· 663 664 664 665 # display summary 665 666 headline = "Build Summary for %s" % program 666 - print "\n", headline, "\n", "=" * len(headline) 667 + print("\n", headline, "\n", "=" * len(headline)) 667 668 if not archivename == "": 668 669 filestats(archivename) 669 670 filestats(archive) ··· 672 673 dursecs = (int)(duration % 60) 673 674 buildmins = (int)(buildtime / 60) 674 675 buildsecs = (int)(buildtime % 60) 675 - print "Overall time %smin %ssec, building took %smin %ssec." % \ 676 - (durmins, dursecs, buildmins, buildsecs) 676 + print("Overall time %smin %ssec, building took %smin %ssec." % \ 677 + (durmins, dursecs, buildmins, buildsecs)) 677 678 678 679 679 680 if __name__ == "__main__": 680 - print "You cannot run this module directly!" 681 - print "Set required environment and call deploy()." 681 + print("You cannot run this module directly!") 682 + print("Set required environment and call deploy().")
+33 -25
utils/common/gitscraper.py
··· 42 42 @return Dict matching hashes to each ref. 43 43 ''' 44 44 print("Getting list of refs") 45 - output = subprocess.Popen(["git", "show-ref", "--abbrev"], 46 - stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 45 + output = subprocess.Popen( 46 + ["git", "show-ref", "--abbrev"], 47 + stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 47 48 cmdout = output.communicate() 48 - refs = {} 49 + refs = dict() 49 50 50 51 if len(cmdout[1]) > 0: 51 52 print("An error occured!\n") ··· 53 54 return refs 54 55 55 56 for line in cmdout: 56 - regex = re.findall(b'([a-f0-9]+)\s+(\S+)', line) 57 + regex = re.findall(b'([a-f0-9]+)\\s+(\\S+)', line) 57 58 for r in regex: 58 59 # ref is the key, hash its value. 59 60 refs[r[1].decode()] = r[0].decode() ··· 61 62 return refs 62 63 63 64 64 - def get_lstree(repo, start, filterlist=[]): 65 + def get_lstree(repo, start, filterlist=None): 65 66 '''Get recursive list of tree objects for a given tree. 66 67 @param repo Path to repository root. 67 68 @param start Hash identifying the tree. ··· 69 70 An empty list will retrieve all paths. 70 71 @return Dict mapping filename to blob hash 71 72 ''' 72 - output = subprocess.Popen(["git", "ls-tree", "-r", start], 73 - stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 73 + if filterlist is None: 74 + filterlist = list() 75 + output = subprocess.Popen( 76 + ["git", "ls-tree", "-r", start], 77 + stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 74 78 cmdout = output.communicate() 75 - objects = {} 79 + objects = dict() 76 80 77 81 if len(cmdout[1]) > 0: 78 82 print("An error occured!\n") ··· 80 84 return objects 81 85 82 86 for line in cmdout[0].decode().split('\n'): 83 - regex = re.findall(b'([0-9]+)\s+([a-z]+)\s+([0-9a-f]+)\s+(.*)', 84 - line.encode()) 87 + regex = re.findall(b'([0-9]+)\\s+([a-z]+)\\s+([0-9a-f]+)\\s+(.*)', 88 + line.encode()) 85 89 for rf in regex: 86 90 # filter 87 91 add = False ··· 107 111 @return Timestamp as string. 108 112 ''' 109 113 output = subprocess.Popen( 110 - ["git", "log", "--format=%ai", "-n", "1", tree, filename], 111 - stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 114 + ["git", "log", "--format=%ai", "-n", "1", tree, filename], 115 + stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 112 116 cmdout = output.communicate() 113 117 114 118 return cmdout[0].decode().rstrip() ··· 121 125 @param destfile filename for blob output. 122 126 @return True if file was successfully written, False on error. 123 127 ''' 124 - output = subprocess.Popen(["git", "cat-file", "-p", blob], 125 - stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 128 + output = subprocess.Popen( 129 + ["git", "cat-file", "-p", blob], 130 + stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 126 131 cmdout = output.communicate() 127 132 # make sure output path exists 128 133 if len(cmdout[1]) > 0: ··· 143 148 @param treehash Hash identifying the tree / commit to describe. 144 149 @return Description string. 145 150 ''' 146 - output = subprocess.Popen(["git", "describe", treehash], 147 - stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 151 + output = subprocess.Popen( 152 + ["git", "describe", treehash], 153 + stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 148 154 cmdout = output.communicate() 149 155 if len(cmdout[1]) > 0: 150 156 print("An error occured!\n") ··· 153 159 return cmdout[0].rstrip() 154 160 155 161 156 - def scrape_files(repo, treehash, filelist, dest="", timestamp_files=[]): 162 + def scrape_files(repo, treehash, filelist, dest=None, timestamp_files=None): 157 163 '''Scrape list of files from repository. 158 164 @param repo Path to repository root. 159 165 @param treehash Hash identifying the tree. ··· 167 173 ''' 168 174 print("Scraping files from repository") 169 175 170 - if dest == "": 176 + if timestamp_files is None: 177 + timestamp_files = list() 178 + if dest is None: 171 179 dest = tempfile.mkdtemp() 172 180 treeobjects = get_lstree(repo, treehash, filelist) 173 181 timestamps = {} ··· 180 188 return [dest, timestamps] 181 189 182 190 183 - def archive_files(repo, treehash, filelist, basename, tmpfolder="", 184 - archive="tbz"): 191 + def archive_files(repo, treehash, filelist, basename, tmpfolder=None, 192 + archive="tbz"): 185 193 '''Archive list of files into tarball. 186 194 @param repo Path to repository root. 187 195 @param treehash Hash identifying the tree. ··· 197 205 @return Output filename. 198 206 ''' 199 207 200 - if tmpfolder == "": 208 + if tmpfolder is None: 201 209 temp_remove = True 202 210 tmpfolder = tempfile.mkdtemp() 203 211 else: 204 212 temp_remove = False 205 - workfolder = scrape_files(repo, treehash, filelist, 206 - os.path.join(tmpfolder, basename))[0] 213 + workfolder = scrape_files( 214 + repo, treehash, filelist, os.path.join(tmpfolder, basename))[0] 207 215 if basename is "": 208 216 return "" 209 217 print("Archiving files from repository") 210 218 if archive == "7z": 211 219 outfile = basename + ".7z" 212 - output = subprocess.Popen(["7z", "a", 213 - os.path.join(os.getcwd(), basename + ".7z"), basename], 220 + output = subprocess.Popen( 221 + ["7z", "a", os.path.join(os.getcwd(), basename + ".7z"), basename], 214 222 cwd=tmpfolder, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 215 223 output.communicate() 216 224 elif archive == "tbz":
+1 -1
utils/common/tarball.py
··· 1 1 #!/usr/bin/python 2 2 3 - import gitscraper 4 3 import os 5 4 import sys 5 + import gitscraper 6 6 7 7 if len(sys.argv) < 2: 8 8 print("Usage: %s <version|hash>" % sys.argv[0])