示例#1
0
    def write_info(self, package_name, patchlevel, git_hash='None'):
        try:
            c = config()
            c.read(CONFIG_FILENAME)
            # New package?
            if not c.has_section(package_name):
                c.add_section(package_name)

            for x in range(1000, 0, -1):
                if c.has_option(package_name, 'last' + str(x)):
                    c.set(package_name, 'last' + str(x +1), c.get(package_name, 'last' + str(x)))
		
            # last-update timestamp
            self.tstamp = str(datetime.now())

            c.set(package_name, 'last1', str(patchlevel) + ',' + str(git_hash) + ',' + str(self.tstamp))
            c.set(package_name, 'patchlevel', str(patchlevel))
            c.set(package_name, 'git_hash', str(git_hash))
            c.set(package_name, 'last_update', self.tstamp)

            with open(CONFIG_FILENAME, 'w') as configfile:
                c.write(configfile)

            log.info('Wrote %s %d %s %s' % (package_name, patchlevel, git_hash, self.tstamp))
        except:
            log.exception('Error writing config file!')
示例#2
0
    def get_info(self, package_name):
        """
        For a package name, return last version and git hash, if any.
        Returns an (int, string, string).
        If a new package, patchlevel is zero.
        """
        try:
            c = config()
            c.read(CONFIG_FILENAME)
            patchlevel = c.getint(package_name, 'patchlevel')
            log.debug('Read %d for %s' % (patchlevel, package_name))
        except:
            log.exception('Error getting info')
            patchlevel = -1

        try:
            git_hash = c.get(package_name, 'git_hash')
        except:
            git_hash = ''

        try:
            tstamp_str = c.get(package_name, 'last_update')
        except:
            tstamp_str = None

        return patchlevel, git_hash, tstamp_str
示例#3
0
    def write_info(self, package_name, patchlevel, git_hash='None'):
        try:
            c = config()
            c.read(CONFIG_FILENAME)
            # New package?
            if not c.has_section(package_name):
                c.add_section(package_name)

            for x in range(1000, 0, -1):
                if c.has_option(package_name, 'last' + str(x)):
                    c.set(package_name, 'last' + str(x + 1),
                          c.get(package_name, 'last' + str(x)))

            # last-update timestamp
            self.tstamp = str(datetime.now())

            c.set(
                package_name, 'last1',
                str(patchlevel) + ',' + str(git_hash) + ',' + str(self.tstamp))
            c.set(package_name, 'patchlevel', str(patchlevel))
            c.set(package_name, 'git_hash', str(git_hash))
            c.set(package_name, 'last_update', self.tstamp)

            with open(CONFIG_FILENAME, 'w') as configfile:
                c.write(configfile)

            log.info('Wrote %s %d %s %s' %
                     (package_name, patchlevel, git_hash, self.tstamp))
        except:
            log.exception('Error writing config file!')
示例#4
0
    def get_info(self, package_name):
        """
        For a package name, return last version and git hash, if any.
        Returns an (int, string, string).
        If a new package, patchlevel is zero.
        """
        try:
            c = config()
            c.read(CONFIG_FILENAME)
            patchlevel = c.getint(package_name, 'patchlevel')
            log.debug('Read %d for %s' % (patchlevel, package_name))
        except:
            log.exception('Error getting info')
            patchlevel = -1

        try:
            git_hash = c.get(package_name, 'git_hash')
        except:
            git_hash = ''

        try:
            tstamp_str = c.get(package_name, 'last_update')
        except:
            tstamp_str = None

        return patchlevel, git_hash, tstamp_str
示例#5
0
	def readConfig (self):
		cfg = config()
		cfg.read ("mailclient.cfg")
		self.fqdn = cfg.get ("mailhost", "fqdn")
		self.imaps = int (cfg.get ("mailhost", "imaps"))
		self.account = cfg.get ("mailbox", "account")
		self.password = cfg.get ("mailbox", "password")
		self.ssl_cert = cfg.get ("ssl", "cert")
示例#6
0
def recursive_if_empty(path):
    """Recursively check if empty; return True
    if everything is empty..."""
    for f in os.listdir(path):
        fp = os.path.join(path, f)
        if not os.path.isdir(fp):
            return False
        else:
            if not recursive_if_empty(fp):
                return False
    return True


b_dir = path.expanduser("~/.buildozer/android/platform/")
conf_path = path.realpath(sys.argv[1])
conf = config(conf_path)
objs = dict({"sdk": SDK, "ndk": NDK})
for thing in ("sdk", "ndk"):
    ver = conf.parseNum("android." + thing)
    if not ver:
        print "ERROR: Invalid version %s for %s" % (str(ver), thing)
        continue
    if thing == "ndk" and ver < 11:
        print "WARN: Too old version %s for %s" % (str(ver), thing)
        print "Buildozer will automatically install that version as this is only a fix for the newer ones (NDK r11+)"
        continue
    n = objs[thing](ver, b_dir)
    if n.exists():
        if recursive_if_empty(n.destDir):
            n.download()
        else:
示例#7
0
    def render_GET(self, request):
        if self.package_name == 'favicon.ico':
            log.debug('Ignoring favicon request')
            return ''

        # We don't need a root page, but it is much more friendly with one.
        if self.package_name == '':
            log.debug('Root page requested')
            header = '<html><head><title>Patchlevel Oracle</title></head><body><h3>Packages</h3>'
            body_prefix = '<p><p>'
            table_header = '<table border="1"><tr><th>Package</th><th>Download</th><th>Git commit hash</th><th>Last update</th></tr>'
            table_footer = '</table>'
            footer = '</nl></body></html>'

            request.write(header)
            request.write(body_prefix)
            request.write(table_header)

            # Try to load and read the config file, each section is a package name
            c = config()
            try:
                c.read(CONFIG_FILENAME)
                sections = c.sections()
                for cur_package in sections:
                    pl, ghash, tstamp = self.get_info(cur_package)
                    if pl == 0:
                      request.write('<tr><td><a href="%s">%s</td><td><a href="http://ooici.net/releases/%s.tar.gz">%s</a></td><td> <A HREF="https://github.com/ooici/ion-object-definitions/commit/%s">%s</a></td><td>%s</td></tr>' %
                                  (cur_package, cur_package, cur_package, cur_package,ghash, ghash, tstamp))
                    else: 
                      request.write('<tr><td><a href="%s">%s</td><td><a href="http://ooici.net/releases/%s.tar.gz">%s</a></td><td> <A HREF="https://github.com/ooici/ion-object-definitions/commit/%s">%s</a></td><td>%s</td></tr>' %
                                  (cur_package, cur_package, cur_package + '-pl' + str(pl), cur_package + '-pl' + str(pl),ghash, ghash, tstamp))
            except:
                pass

            request.write(table_footer)
            request.write(footer)

            return ''


        # if a git_hash is present, then we bump the count, and return the count.
        if self.git_hash != None:    
          # We actually return the entry from the file
          patchlevel, git_hash, timestamp = self.get_info(self.package_name)
          # Write next entry
          patchlevel += 1
          self.write_info(self.package_name, patchlevel, self.git_hash)
          return(str(patchlevel))


        """
        This is actually the normal case, have requested a package via REST URL
         e.g. 'GET /nimboss?git_hash=7abcdefg'
        git_hash is optional
        """
        # read previous entry
        try:
            c = config()
            c.read(CONFIG_FILENAME)
            patchlevel = c.getint(self.package_name, 'patchlevel')
        except:
            log.exception('Error getting info')
            patchlevel = -1

        patchlevel, git_hash, timestamp = self.get_info(self.package_name)
        # Write next entry
        # We actually return the entry from the file

        try:
            git_hash = c.get(self.package_name, 'git_hash')
        except:
            git_hash = ''

        try:
            tstamp_str = c.get(self.package_name, 'last_update')
        except:
            tstamp_str = None



        header = '<html><head><title>Patchlevel Oracle</title></head><body><h3>Packages</h3>'
        body_prefix = '<p>Recent version history for ' + self.package_name + '<p>'
        table_header = '<table border="1"><tr><th>Info</th><th>Download</th><th>Git commit hash</th><th>Last update</th></tr>'
        table_footer = '</table>'
        footer = '</nl></body></html>'
        request.write(header)
        request.write(body_prefix)
        request.write(table_header)
        if patchlevel == 0:
          request.write('<tr><td>%s</td><td><a href="http://ooici.net/releases/%s.tar.gz">%s</a></td><td><a href="https://github.com/ooici/ion-object-definitions/commit/%s">%s</a></td><td>%s</td></tr>' %
                       ('Current', self.package_name, self.package_name, git_hash, git_hash, tstamp_str))
        else:
          request.write('<tr><td>%s</td><td><a href="http://ooici.net/releases/%s.tar.gz">%s</a></td><td><a href="https://github.com/ooici/ion-object-definitions/commit/%s">%s</a></td><td>%s</td></tr>' %
                       ('Current', self.package_name + '-pl' + str(patchlevel), self.package_name + '-pl' + str(patchlevel), git_hash, git_hash, tstamp_str))
       
        for x in range(2,1000):
            try:
                s = c.get(self.package_name, 'last' + str(x))
                items = s.split(',')
                if items[0] == '0':
                  request.write('<tr><td>%s</td><td><a href="http://ooici.net/releases/%s.tar.gz">%s</a></td><td><a href="https://github.com/ooici/ion-object-definitions/commit/%s">%s</a></td><td>%s</td></tr>' %
                               ('Historical',  self.package_name, self.package_name, items[1], items[1], items[2]))
                else: 
                  request.write('<tr><td>%s</td><td><a href="http://ooici.net/releases/%s.tar.gz">%s</a></td><td><a href="https://github.com/ooici/ion-object-definitions/commit/%s">%s</a></td><td>%s</td></tr>' %
                               ('Historical',  self.package_name + '-pl' + items[0], self.package_name + '-pl' + items[0], items[1], items[1], items[2]))
            except:
                """
                """

        request.write(table_footer)
        request.write(footer)

        return ''
示例#8
0
    def render_GET(self, request):
        if self.package_name == 'favicon.ico':
            log.debug('Ignoring favicon request')
            return ''

        # We don't need a root page, but it is much more friendly with one.
        if self.package_name == '':
            log.debug('Root page requested')
            header = '<html><head><title>Patchlevel Oracle</title></head><body><h3>Packages</h3>'
            body_prefix = '<p><p>'
            table_header = '<table border="1"><tr><th>Package</th><th>Download</th><th>Git commit hash</th><th>Last update</th></tr>'
            table_footer = '</table>'
            footer = '</nl></body></html>'

            request.write(header)
            request.write(body_prefix)
            request.write(table_header)

            # Try to load and read the config file, each section is a package name
            c = config()
            try:
                c.read(CONFIG_FILENAME)
                sections = c.sections()
                for cur_package in sections:
                    pl, ghash, tstamp = self.get_info(cur_package)
                    if pl == 0:
                        request.write(
                            '<tr><td><a href="%s">%s</td><td><a href="http://ooici.net/releases/%s.tar.gz">%s</a></td><td> <A HREF="https://github.com/ooici/ion-object-definitions/commit/%s">%s</a></td><td>%s</td></tr>'
                            % (cur_package, cur_package, cur_package,
                               cur_package, ghash, ghash, tstamp))
                    else:
                        request.write(
                            '<tr><td><a href="%s">%s</td><td><a href="http://ooici.net/releases/%s.tar.gz">%s</a></td><td> <A HREF="https://github.com/ooici/ion-object-definitions/commit/%s">%s</a></td><td>%s</td></tr>'
                            % (cur_package, cur_package, cur_package + '-pl' +
                               str(pl), cur_package + '-pl' + str(pl), ghash,
                               ghash, tstamp))
            except:
                pass

            request.write(table_footer)
            request.write(footer)

            return ''

        # if a git_hash is present, then we bump the count, and return the count.
        if self.git_hash != None:
            # We actually return the entry from the file
            patchlevel, git_hash, timestamp = self.get_info(self.package_name)
            # Write next entry
            patchlevel += 1
            self.write_info(self.package_name, patchlevel, self.git_hash)
            return (str(patchlevel))
        """
        This is actually the normal case, have requested a package via REST URL
         e.g. 'GET /nimboss?git_hash=7abcdefg'
        git_hash is optional
        """
        # read previous entry
        try:
            c = config()
            c.read(CONFIG_FILENAME)
            patchlevel = c.getint(self.package_name, 'patchlevel')
        except:
            log.exception('Error getting info')
            patchlevel = -1

        patchlevel, git_hash, timestamp = self.get_info(self.package_name)
        # Write next entry
        # We actually return the entry from the file

        try:
            git_hash = c.get(self.package_name, 'git_hash')
        except:
            git_hash = ''

        try:
            tstamp_str = c.get(self.package_name, 'last_update')
        except:
            tstamp_str = None

        header = '<html><head><title>Patchlevel Oracle</title></head><body><h3>Packages</h3>'
        body_prefix = '<p>Recent version history for ' + self.package_name + '<p>'
        table_header = '<table border="1"><tr><th>Info</th><th>Download</th><th>Git commit hash</th><th>Last update</th></tr>'
        table_footer = '</table>'
        footer = '</nl></body></html>'
        request.write(header)
        request.write(body_prefix)
        request.write(table_header)
        if patchlevel == 0:
            request.write(
                '<tr><td>%s</td><td><a href="http://ooici.net/releases/%s.tar.gz">%s</a></td><td><a href="https://github.com/ooici/ion-object-definitions/commit/%s">%s</a></td><td>%s</td></tr>'
                % ('Current', self.package_name, self.package_name, git_hash,
                   git_hash, tstamp_str))
        else:
            request.write(
                '<tr><td>%s</td><td><a href="http://ooici.net/releases/%s.tar.gz">%s</a></td><td><a href="https://github.com/ooici/ion-object-definitions/commit/%s">%s</a></td><td>%s</td></tr>'
                % ('Current', self.package_name + '-pl' + str(patchlevel),
                   self.package_name + '-pl' + str(patchlevel), git_hash,
                   git_hash, tstamp_str))

        for x in range(2, 1000):
            try:
                s = c.get(self.package_name, 'last' + str(x))
                items = s.split(',')
                if items[0] == '0':
                    request.write(
                        '<tr><td>%s</td><td><a href="http://ooici.net/releases/%s.tar.gz">%s</a></td><td><a href="https://github.com/ooici/ion-object-definitions/commit/%s">%s</a></td><td>%s</td></tr>'
                        % ('Historical', self.package_name, self.package_name,
                           items[1], items[1], items[2]))
                else:
                    request.write(
                        '<tr><td>%s</td><td><a href="http://ooici.net/releases/%s.tar.gz">%s</a></td><td><a href="https://github.com/ooici/ion-object-definitions/commit/%s">%s</a></td><td>%s</td></tr>'
                        % ('Historical', self.package_name + '-pl' + items[0],
                           self.package_name + '-pl' + items[0], items[1],
                           items[1], items[2]))
            except:
                """
                """

        request.write(table_footer)
        request.write(footer)

        return ''
示例#9
0
def read_inifile(filename="config.ini", defaults={}):
    if not os.path.isfile(filename): return None
    inifile = config(defaults)
    inifile.read(filename)
    return inifile