mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
made changes to move some confs
This commit is contained in:
parent
94e2a43574
commit
9c0af6358a
2 changed files with 17 additions and 11 deletions
|
@ -30,15 +30,13 @@ import os.path
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
CACHEDIR = '/var/cache/tupkgs/'
|
|
||||||
INCOMINGDIR = '/var/cache/tupkgs/incomplete/'
|
|
||||||
CONFIGFILE = '/etc/tupkgs.conf'
|
CONFIGFILE = '/etc/tupkgs.conf'
|
||||||
|
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
|
|
||||||
class ClientFile:
|
class ClientFile:
|
||||||
def __init__(self, filename, actual_size, actual_md5):
|
def __init__(self, filename, actual_size, actual_md5):
|
||||||
self.pathname = INCOMINGDIR + filename
|
self.pathname = confdict['incomingdir'] + filename
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.fd = open(self.pathname, "a+b")
|
self.fd = open(self.pathname, "a+b")
|
||||||
self.actual_size = actual_size
|
self.actual_size = actual_size
|
||||||
|
@ -64,7 +62,7 @@ class ClientFile:
|
||||||
|
|
||||||
def finishDownload(self):
|
def finishDownload(self):
|
||||||
self.fd.close()
|
self.fd.close()
|
||||||
newpathname = CACHEDIR + self.filename
|
newpathname = confdict['cachedir'] + self.filename
|
||||||
os.rename(self.pathname, newpathname)
|
os.rename(self.pathname, newpathname)
|
||||||
self.pathname = newpathname
|
self.pathname = newpathname
|
||||||
self.fd = open(self.pathname, "a+b")
|
self.fd = open(self.pathname, "a+b")
|
||||||
|
@ -229,6 +227,8 @@ def usage(name):
|
||||||
def getDefaultConfig():
|
def getDefaultConfig():
|
||||||
confdict = {}
|
confdict = {}
|
||||||
confdict['port'] = 1034
|
confdict['port'] = 1034
|
||||||
|
confdict['cachedir'] = '/var/cache/tupkgs/'
|
||||||
|
confdict['incomingdir'] = '/var/cache/tupkgs/incomplete/'
|
||||||
confdict['maxqueue'] = 5
|
confdict['maxqueue'] = 5
|
||||||
|
|
||||||
return confdict
|
return confdict
|
||||||
|
@ -267,6 +267,10 @@ def main(argv=None):
|
||||||
confdict['port'] = config.getint('tupkgs', 'port')
|
confdict['port'] = config.getint('tupkgs', 'port')
|
||||||
if config.has_option('tupkgs', 'maxqueue'):
|
if config.has_option('tupkgs', 'maxqueue'):
|
||||||
confdict['maxqueue'] = config.getint('tupkgs', 'maxqueue')
|
confdict['maxqueue'] = config.getint('tupkgs', 'maxqueue')
|
||||||
|
if config.has_option('tupkgs', 'cachedir'):
|
||||||
|
confdict['cachedir'] = config.get('tupkgs', 'cachedir')
|
||||||
|
if config.has_option('tupkgs', 'incomingdir'):
|
||||||
|
confdict['incomingdir'] = config.get('tupkgs', 'incomingdir')
|
||||||
|
|
||||||
print "Connecting to MySQL database"
|
print "Connecting to MySQL database"
|
||||||
dbconn = MySQLdb.connect(host=config.get('mysql', 'host'),
|
dbconn = MySQLdb.connect(host=config.get('mysql', 'host'),
|
||||||
|
@ -274,13 +278,13 @@ def main(argv=None):
|
||||||
passwd=config.get('mysql', 'password'),
|
passwd=config.get('mysql', 'password'),
|
||||||
db=config.get('mysql', 'db'))
|
db=config.get('mysql', 'db'))
|
||||||
|
|
||||||
print "Verifying "+CACHEDIR+" and "+INCOMINGDIR+" exist"
|
print "Verifying "+confdict['cachedir']+" and "+confdict['incomingdir']+" exist"
|
||||||
if not os.path.isdir(CACHEDIR):
|
if not os.path.isdir(confdict['cachedir']):
|
||||||
print "Creating "+CACHEDIR
|
print "Creating "+confdict['cachedir']
|
||||||
os.mkdir(CACHEDIR, 0755)
|
os.mkdir(confdict['cachedir'], 0755)
|
||||||
if not os.path.isdir(INCOMINGDIR):
|
if not os.path.isdir(confdict['incomingdir']):
|
||||||
print "Creating "+INCOMINGDIR
|
print "Creating "+confdict['incomingdir']
|
||||||
os.mkdir(INCOMINGDIR, 0755)
|
os.mkdir(confdict['incomingdir'], 0755)
|
||||||
|
|
||||||
print "Starting ServerSocket"
|
print "Starting ServerSocket"
|
||||||
servsock = ServerSocket(dbconn, confdict['port'], confdict['maxqueue'])
|
servsock = ServerSocket(dbconn, confdict['port'], confdict['maxqueue'])
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
[tupkgs]
|
[tupkgs]
|
||||||
port = 1034
|
port = 1034
|
||||||
|
cachedir = '/var/cache/tupkgs/'
|
||||||
|
incomingdir = '/var/cache/tupkgs/incomplete/'
|
||||||
|
|
||||||
[mysql]
|
[mysql]
|
||||||
username = aur
|
username = aur
|
||||||
|
|
Loading…
Add table
Reference in a new issue