X-Git-Url: https://git.tld-linux.org/?a=blobdiff_plain;f=TLD_Builder%2Frequest.py;h=039cf76627cc7821edac766ec19a419a4d8e937a;hb=92949e17161a53bfb4a60099e22b58ad63abce4c;hp=27bc426364538a683cf287a487d8e84dcd4bffc8;hpb=b999f53d4bf5d44586ecf028876e8bc20b5fd2ce;p=tld-builder.git diff --git a/TLD_Builder/request.py b/TLD_Builder/request.py index 27bc426..039cf76 100644 --- a/TLD_Builder/request.py +++ b/TLD_Builder/request.py @@ -16,7 +16,6 @@ import util import log from acl import acl from config import config -from subprocess import call __all__ = ['parse_request', 'parse_requests'] @@ -39,6 +38,20 @@ def attr(e, a, default = None): def escape(s): return xml.sax.saxutils.escape(s) +# return timestamp with timezone information +# so we could parse it in javascript +def tzdate(t): + # as strftime %z is unofficial, and does not work, need to make it numeric ourselves + date = time.strftime("%a %b %d %Y %H:%M:%S", time.localtime(t)) + # NOTE: the altzone is showing CURRENT timezone, not what the "t" reflects + # NOTE: when DST is off timezone gets it right, altzone not + if time.daylight: + tzoffset = time.altzone + else: + tzoffset = time.timezone + tz = '%+05d' % (-tzoffset / 3600 * 100) + return date + ' ' + tz + # return date in iso8601 format def iso8601(ts, timezone='UTC'): tz = pytz.timezone(timezone) @@ -103,17 +116,34 @@ class Group: b.dump(f) f.write("\n") + # return structure usable for json encoding + def dump_json(self): + batches = [] + for b in self.batches: + batches.append(b.dump_json()) + + return dict( + no=self.no, + id=self.id, + time=self.time, + requester=self.requester, + priority=self.priority, + max_jobs=self.max_jobs, + flags=self.flags, + batches=batches, + ) + def dump_html(self, f): f.write( "
%sflags: [%s]" % (self.command, ' '.join(self.command_flags)) else: - cmd = "/usr/bin/git ls-remote --heads git://git.tld-linux.org/packages/%s 1>/dev/null 2>&1" % (self.spec[:-5]) - r = call(cmd, shell=True) - if r == 0: - dist = "tld" - else: - dist = "pld" - package_url = "http://git.%(dist)s-linux.org/?p=packages/%(package)s.git;a=blob;f=%(spec)s;hb=%(branch)s" % { - 'dist': dist, - 'spec': urllib.quote(self.spec), - 'branch': urllib.quote(self.branch), - 'package': urllib.quote(self.spec[:-5]), - } + cmd = "/usr/bin/git ls-remote --heads git://git.tld-linux.org/packages/%s 1>/dev/null 2>&1" % (self.spec[:-5]) + r = call(cmd, shell=True) + if r == 0: + package_url = "http://git.tld-linux.org/?p=packages/%(package)s.git;a=blob;f=%(spec)s;hb=%(branch)s" % { + 'spec': urllib.quote(self.spec), + 'branch': urllib.quote(self.branch), + 'package': urllib.quote(self.spec[:-5]), + } + else: + package_url = "http://git.pld-linux.org/gitweb.cgi?p=packages/%(package)s.git;f=%(spec)s;h=%(branch)s;a=shortlog" % { + 'spec': urllib.quote(self.spec), + 'branch': urllib.quote(self.branch), + 'package': urllib.quote(self.spec[:-5]), + } desc = "%(src_rpm)s (%(spec)s -r %(branch)s%(rpmopts)s)" % { 'src_rpm': self.src_rpm, 'spec': self.spec, @@ -350,20 +416,9 @@ class Batch: "--define '_builddir %{_topdir}/BUILD' " return rpmdefs + rpmopts - def php_ignores(self): - # transform php package name (52) to version (5.2) - def php_name_to_ver(v): - return '.'.join(list(v)) - - # transform php version (5.2) to package name (52) - def php_ver_to_name(v): - return v.replace('.', '') - + def php_ignores(self, php_version): # available php versions in distro - php_versions = ['4', '5.2', '5.3', '5.4', '5.5', '5.6', '7.0'] - - # current version if -D php_suffix is present - php_version = php_name_to_ver(self.defines['php_suffix']) + php_versions = ['7.2', '7.3', '7.4', '8.0'] # remove current php version try: @@ -375,7 +430,7 @@ class Batch: # map them to poldek ignores # always ignore hhvm res = ['hhvm-*'] - for v in map(php_ver_to_name, php_versions): + for v in list(map(php_ver_to_name, php_versions)): res.append("php%s-*" % v) return res @@ -387,7 +442,12 @@ class Batch: # add php version based ignores if self.defines.has_key('php_suffix'): - ignores.extend(self.php_ignores()) + # current version if -D php_suffix is present + php_version = php_name_to_ver(self.defines['php_suffix']) + else: + php_version = self.DEFAULT_PHP + + ignores.extend(self.php_ignores(php_version)) # return empty string if the list is empty if len(ignores) == 0: @@ -396,7 +456,7 @@ class Batch: def add_ignore(s): return "--ignore=%s" % s - return " ".join(map(add_ignore, ignores)) + return " ".join(list(map(add_ignore, ignores))) def kernel_string(self): r = "" @@ -441,7 +501,7 @@ class Batch: