pld-ftp-admin: scripts/from-incoming.py - keep functions in front and then ...
glen
glen at pld-linux.org
Thu Jun 11 23:57:50 CEST 2009
Author: glen Date: Thu Jun 11 21:57:50 2009 GMT
Module: pld-ftp-admin Tag: HEAD
---- Log message:
- keep functions in front and then the main code
---- Files affected:
pld-ftp-admin/scripts:
from-incoming.py (1.18 -> 1.19)
---- Diffs:
================================================================
Index: pld-ftp-admin/scripts/from-incoming.py
diff -u pld-ftp-admin/scripts/from-incoming.py:1.18 pld-ftp-admin/scripts/from-incoming.py:1.19
--- pld-ftp-admin/scripts/from-incoming.py:1.18 Wed May 27 00:46:01 2009
+++ pld-ftp-admin/scripts/from-incoming.py Thu Jun 11 23:57:44 2009
@@ -7,13 +7,9 @@
import config
from common import noarchcachedir, tmpdir, fileexists
from baseftptree import BaseFtpTree, BasePkg
-cval=config.value
+cval = config.value
import ftpio
-
-try:
- ftpio.connect('from-incoming-pid-%s' % os.getpid())
-except:
- sys.exit(0)
+import rpm
def rm(file):
os.remove(file)
@@ -21,6 +17,11 @@
def mv(src, dst):
os.rename(src, dst + '/' + src.split('/')[-1])
+def pkg_contents(pkg):
+ print "pkg: %s" % pkg
+ # hardcoded tree name
+ maintree = BaseFtpTree("PLD")
+
# duplicate code in ftptree.py
def is_debuginfo(nvr):
"""
@@ -48,37 +49,6 @@
else:
return content[:-4]
-ftptree = BaseFtpTree(cval['default_to'])
-
-if not ftpio.lock(cval['default_to']):
- sys.exit(0)
-
-for uploadinfo in findfiles(incoming_dir + 'SRPMS'):
- content = getcontent(incoming_dir + 'SRPMS/' + uploadinfo)
- if not content:
- continue # Uploading not finished
-
- pkg = BasePkg(uploadinfo[:-19], content = content)
- srpm = pkg.files['SRPMS'][0]
-
- if ftptree.has_key(`pkg`):
- ftpio.log("%s already present in %s; removing newer files" % (srpm, ftptree))
- rm(incoming_dir + 'SRPMS/' + srpm)
- f = open(default_to + 'SRPMS/.metadata/' + srpm+'.info', 'a')
- bid = pkg.build.keys()[0]
- build = pkg.build[bid]
- f.write("info:build:%s:requester:%s\ninfo:build:%s:requester_email:%s\n"
- % (bid, build.requester, bid, build.requester_email))
- f.close()
- else:
- mv(incoming_dir + 'SRPMS/' + srpm, default_to + 'SRPMS/RPMS')
-
- f = open(default_to + 'SRPMS/.metadata/' + srpm + '.info', 'w')
- f.write(content)
- f.close()
-
- rm(incoming_dir + 'SRPMS/' + uploadinfo)
-
def send_noarch_msg(files_differ, reqs_differ, pkg, rpm, arch):
req_email=pkg.build[pkg.lastbid].requester_email
req_bid=pkg.lastbid
@@ -127,8 +97,6 @@
sm.close()
-
-
def move_noarch(f, arch, rpm, dstpkg):
if dstpkg.noarch_arch.has_key(rpm):
os.system("rpm -qlp %s | LC_ALL=C sort > %s/files.new" %
@@ -157,6 +125,45 @@
(incoming_dir + arch + '/' + rpm, noarchcachedir, rpm))
f.write("file:noarch:%s\ninfo:noarch_arch:%s:%s\n" % (rpm, rpm, arch))
mv(incoming_dir + arch + '/' + rpm, default_to + 'noarch/RPMS')
+
+# main()
+try:
+ ftpio.connect('from-incoming-pid-%s' % os.getpid())
+except:
+ sys.exit(0)
+
+ftptree = BaseFtpTree(cval['default_to'])
+
+if not ftpio.lock(cval['default_to']):
+ sys.exit(0)
+
+for uploadinfo in findfiles(incoming_dir + 'SRPMS'):
+ content = getcontent(incoming_dir + 'SRPMS/' + uploadinfo)
+ if not content:
+ continue # Uploading not finished
+
+ pkg = BasePkg(uploadinfo[:-19], content = content)
+ srpm = pkg.files['SRPMS'][0]
+
+ if ftptree.has_key(`pkg`):
+ ftpio.log("%s already present in %s; removing newer files" % (srpm, ftptree))
+ rm(incoming_dir + 'SRPMS/' + srpm)
+ f = open(default_to + 'SRPMS/.metadata/' + srpm+'.info', 'a')
+ bid = pkg.build.keys()[0]
+ build = pkg.build[bid]
+ f.write("info:build:%s:requester:%s\ninfo:build:%s:requester_email:%s\n"
+ % (bid, build.requester, bid, build.requester_email))
+ f.close()
+ else:
+ mv(incoming_dir + 'SRPMS/' + srpm, default_to + 'SRPMS/RPMS')
+
+ f = open(default_to + 'SRPMS/.metadata/' + srpm + '.info', 'w')
+ f.write(content)
+ f.close()
+
+ rm(incoming_dir + 'SRPMS/' + uploadinfo)
+
+
for arch in ftp_archs:
for uploadinfo in findfiles(incoming_dir+arch):
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-ftp-admin/scripts/from-incoming.py?r1=1.18&r2=1.19&f=u
More information about the pld-cvs-commit
mailing list