mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +02:00
buildserver: move code into main() method to always stop thread
By running the whole program in a main() function, it can be wrapped in try/finally in order to stop the background display thread. This is also done in ./fdroid, its standard practice for Python CLI utilities.
This commit is contained in:
parent
675500ad88
commit
6464ec55b7
@ -20,7 +20,7 @@ if not os.path.exists('makebuildserver') and not os.path.exists('buildserver'):
|
|||||||
|
|
||||||
|
|
||||||
boxfile = os.path.join(os.getcwd(), 'buildserver.box')
|
boxfile = os.path.join(os.getcwd(), 'buildserver.box')
|
||||||
serverdir = 'buildserver'
|
tail = None
|
||||||
|
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||||
@ -293,6 +293,9 @@ def sha256_for_file(path):
|
|||||||
return s.hexdigest()
|
return s.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
global cachedir, cachefiles, config, tail
|
||||||
|
|
||||||
for srcurl, shasum in cachefiles:
|
for srcurl, shasum in cachefiles:
|
||||||
filename = os.path.basename(srcurl)
|
filename = os.path.basename(srcurl)
|
||||||
local_filename = os.path.join(cachedir, filename)
|
local_filename = os.path.join(cachedir, filename)
|
||||||
@ -362,6 +365,7 @@ elif os.path.exists('/proc/cpuinfo'):
|
|||||||
if 'vmx' in contents or 'svm' in contents:
|
if 'vmx' in contents or 'svm' in contents:
|
||||||
config['hwvirtex'] = 'on'
|
config['hwvirtex'] = 'on'
|
||||||
|
|
||||||
|
serverdir = os.path.join(os.getcwd(), 'buildserver')
|
||||||
logfilename = os.path.join(serverdir, 'up.log')
|
logfilename = os.path.join(serverdir, 'up.log')
|
||||||
if not os.path.exists(logfilename):
|
if not os.path.exists(logfilename):
|
||||||
open(logfilename, 'a').close() # create blank file
|
open(logfilename, 'a').close() # create blank file
|
||||||
@ -446,5 +450,10 @@ v.box_add('buildserver', boxfile, force=True)
|
|||||||
|
|
||||||
os.remove(boxfile)
|
os.remove(boxfile)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
|
main()
|
||||||
|
finally:
|
||||||
if tail is not None:
|
if tail is not None:
|
||||||
tail.stop()
|
tail.stop()
|
||||||
|
Loading…
Reference in New Issue
Block a user