Example #1
0
    def get(self, request):
        if request.endswith(".zip") and "/" not in request:
            fileobj = File.get_by_filename(request)
        elif request.endswith(".zip") and "/" in request:
            fileobj = File.get_by_fullpath(request)
        else:
            fileobj = File.get_by_base62(request)

        if fileobj is None:
            self.write("404 Not Found")
            return self.set_status(404)

        return self.write("%s  %s" % (fileobj.filename, fileobj.md5sum))
Example #2
0
    def method_get_all_builds(self):
        channels = self.params.get('channels', None)
        device = self.params.get('device', None)
        limit = int(self.params.get('limit', 3))
        if not channels or not device:
            self.set_status(500)
            return self.fail("Invalid Parameters")

        cache_key = 'api_all_%s_%s_%s' % (device, "_".join(sorted(channels)), str(limit))
        result = cache.get(cache_key)
        if result is not None:
            return self.success(result)

        result = []

        if 'snapshot' in channels and 'RC' not in channels:
            channels.append('RC')

        for channel in channels:
            files = File.browse(device, channel, limit)
            for file_obj in files:
                if file_obj is not None:
                    changesfile = re.sub(file_obj.filename, "CHANGES.txt", file_obj.full_path)
                    result.append({
                        'channel': channel,
                        'filename': file_obj.filename,
                        'url': "http://get.dazzozo.org/get/%s" % file_obj.full_path,
                        'changes': "http://get.galliumos.org/get/%s" % changesfile,
                        'md5sum': file_obj.md5sum,
                        'timestamp': file_obj.date_created.strftime('%s')
                    })

        cache.set(cache_key, result)

        return self.success(result)
Example #3
0
    def get(self):
        device = self.request.arguments.get('device', [None])[0]
        type = self.request.arguments.get('type', [None])[0]
        files = File.browse(device, type)

        for fileobj in files:
            fileobj.base62 = base62_encode(fileobj.id)

        devicelist = Device.get_all()

        # Set default values for device names dictionary
        devicedict = {}
        for codename in devicelist:
            if codename in devicemap:
                devicedict[codename] = devicemap[codename]
            else:
                devicedict[codename] = codename

        return self.render(
            "browse.mako", {
                'request_type': type,
                'request_device': device,
                'devices': devicelist,
                'devicenames': devicedict,
                'files': files
            })
Example #4
0
    def get(self, request):
        request = request + ".zip"

        if request.endswith("-latest.zip"):
            device = request.replace("-latest.zip", "")
            fileobj = File.get_latest_by_device(device)
        elif "/" in request:
            fileobj = File.get_by_fullpath(request)
        elif "/" not in request:
            fileobj = File.get_by_filename(request)

        if fileobj is None and "/" not in request:
            self.write("404 Not Found")
            return self.set_status(404)
        elif fileobj is None:
            full_path = request
        else:
            full_path = fileobj.full_path

        url = self.mirrorpool.next() % full_path

        return self.redirect(url)
Example #5
0
 def run(self):
     for build in self.get_builds():
         artifactlist = self.get_artifact(build)
         if artifactlist:
             for artifactdata in artifactlist:
                 artifact, timestamp = artifactdata
                 full_path = "jenkins/%s/%s" % (artifact.split("/")[5],
                                                artifact.split("/")[-1])
                 if os.path.exists("/var/www/mirror/%s" % full_path):
                     print "Exists, skipping."
                     continue
                 fileobj = File.get_by_fullpath(full_path)
                 if not fileobj:
                     base = "artifacts/%s" % artifact.replace(
                         "https://ci.galliumos.org/job/GalliumOS-Nightlies/",
                         "")
                     build_number = base.split("/")[1]
                     fname = base.split("/")[-1]
                     build_type = "nightly"
                     if "RELEASE" in artifact:
                         build_type = "release"
                     if "RC" in artifact:
                         build_type = "RC"
                     if "BETA" in artifact:
                         build_type = "beta"
                     #cmd = "/usr/local/bin/getgos.addfile --timestamp %s --url %s --fullpath %s --type %s --config %s" % (timestamp, artifact, base, build_type, self.configPath)
                     try:
                         os.mkdir("/var/www/mirror/jenkins/%s" %
                                  build_number)
                     except:
                         pass
                     download_cmd = "wget -O /var/www/mirror/jenkins/%s/%s %s" % (
                         build_number, fname, artifact)
                     print "Running: %s" % download_cmd
                     os.system(download_cmd)
                     if (fname != "CHANGES.txt"):
                         #mirror_cmd = "ssh -p2200 [email protected] \"/root/add.sh /srv/mirror/jenkins/%s %s %s\"" % (build_number, artifact, fname)
                         #print "Running: %s" % mirror_cmd
                         #os.system(mirror_cmd)
                         addfile_cmd = "/usr/local/bin/getgos.addfile --timestamp %s --file /var/www/mirror/jenkins/%s/%s --fullpath jenkins/%s/%s --type %s --config %s" % (
                             timestamp, build_number, fname, build_number,
                             fname, build_type, self.configPath)
                         print "Running: %s" % addfile_cmd
                         os.system(addfile_cmd)
Example #6
0
    def method_get_all_builds(self):
        channels = self.params.get('channels', None)
        device = self.params.get('device', None)
        limit = int(self.params.get('limit', 3))
        if not channels or not device:
            self.set_status(500)
            return self.fail("Invalid Parameters")

        cache_key = 'api_all_%s_%s_%s' % (device, "_".join(
            sorted(channels)), str(limit))
        result = cache.get(cache_key)
        if result is not None:
            return self.success(result)

        result = []

        if 'snapshot' in channels and 'RC' not in channels:
            channels.append('RC')

        for channel in channels:
            files = File.browse(device, channel, limit)
            for file_obj in files:
                if file_obj is not None:
                    changesfile = re.sub(file_obj.filename, "CHANGES.txt",
                                         file_obj.full_path)
                    result.append({
                        'channel':
                        channel,
                        'filename':
                        file_obj.filename,
                        'url':
                        "http://get.dazzozo.org/get/%s" % file_obj.full_path,
                        'changes':
                        "http://get.galliumos.org/get/%s" % changesfile,
                        'md5sum':
                        file_obj.md5sum,
                        'timestamp':
                        file_obj.date_created.strftime('%s')
                    })

        cache.set(cache_key, result)

        return self.success(result)
Example #7
0
    def get(self):
        device = self.request.arguments.get('device', [None])[0]
        type = self.request.arguments.get('type', [None])[0]
        files = File.browse(device, type)

        for fileobj in files:
            fileobj.base62 = base62_encode(fileobj.id)

        devicelist = Device.get_all()

        # Set default values for device names dictionary
        devicedict = {}
        for codename in devicelist:
            if codename in devicemap:
                devicedict[codename] = devicemap[codename]
            else:
                devicedict[codename] = codename

        return self.render("browse.mako", {'request_type': type, 'request_device': device, 'devices': devicelist, 'devicenames': devicedict, 'files': files})
    def get(self, request):
        # Some torrent clients are retarded and urlencode the querystring.
        # if that happens, they don't deserve to download.
        if request.endswith("?webseed=1"):
            self.write("403 Forbidden")
            return self.set_status(403)

        fileobj = File.get_by_base62(request)
        if fileobj is None:
            self.write("404 Not Found")
            return self.set_status(404)

        # Determine mirror to use
        url = self.mirrorpool.next() % fileobj.full_path

        webseed = self.request.arguments.get('webseed', [None])[0]
        if webseed:
            url = url + "?" + urllib.urlencode({'webseed': webseed})
            logging.warn("Webseeding for '%s'" % fileobj.filename)

        return self.redirect(url)
Example #9
0
 def run(self):
     for build in self.get_builds():
         artifactlist = self.get_artifact(build)
         if artifactlist:
             for artifactdata in artifactlist:
                 artifact, timestamp = artifactdata
                 full_path = "jenkins/%s/%s" % (artifact.split("/")[5], artifact.split("/")[-1])
                 if os.path.exists("/var/www/mirror/%s" % full_path):
                     print "Exists, skipping."
                     continue
                 fileobj = File.get_by_fullpath(full_path)
                 if not fileobj:
                     base = "artifacts/%s" % artifact.replace("https://ci.galliumos.org/job/GalliumOS-Nightlies/", "")
                     build_number = base.split("/")[1]
                     fname = base.split("/")[-1]
                     build_type = "nightly"
                     if "RELEASE" in artifact:
                         build_type = "release"
                     if "RC" in artifact:
                         build_type = "RC"
                     if "BETA" in artifact:
                         build_type = "beta"
                     #cmd = "/usr/local/bin/getgos.addfile --timestamp %s --url %s --fullpath %s --type %s --config %s" % (timestamp, artifact, base, build_type, self.configPath)
                     try:
                         os.mkdir("/var/www/mirror/jenkins/%s" % build_number)
                     except:
                         pass
                     download_cmd = "wget -O /var/www/mirror/jenkins/%s/%s %s" % (build_number, fname, artifact)
                     print "Running: %s" % download_cmd
                     os.system(download_cmd)
                     if (fname != "CHANGES.txt"):
                         #mirror_cmd = "ssh -p2200 [email protected] \"/root/add.sh /srv/mirror/jenkins/%s %s %s\"" % (build_number, artifact, fname)
                         #print "Running: %s" % mirror_cmd
                         #os.system(mirror_cmd)
                         addfile_cmd = "/usr/local/bin/getgos.addfile --timestamp %s --file /var/www/mirror/jenkins/%s/%s --fullpath jenkins/%s/%s --type %s --config %s" % (timestamp, build_number, fname, build_number, fname, build_type, self.configPath)
                         print "Running: %s" % addfile_cmd
                         os.system(addfile_cmd)
def process_file(args):
    init_database(create_engine(args.db_uri))
    session = DBSession()

    md5hash = md5sum(args.file)
    new = File.get_by_md5sum(md5hash)
    if new is None:
        new = File()
        new.md5sum = md5hash

    if args.url:
        new.filename = os.path.basename(args.url)
    else:
        new.filename = os.path.basename(args.file)

    if args.full_path:
        new.full_path = args.full_path
    else:
        new.full_path = args.file.replace(args.base_path, "")

    new.type = args.type
    new.size = os.path.getsize(args.file)
    new.device = args.device
    if args.timestamp is not None:
        new.date_created = datetime.fromtimestamp(args.timestamp)
    else:
        new.date_created = datetime.fromtimestamp(os.path.getmtime(args.file))

    logging.debug("Filename = %s", new.filename)
    logging.debug("Type = %s", new.type)
    logging.debug("Device = %s", new.device)
    logging.debug("MD5 = %s", new.md5sum)

    try:
        session.add(new)
        session.commit()
        logging.info("File added successfully!")
    except IntegrityError:
        session.rollback()
        logging.error("File already exists: '%s'", new.filename)

    if args.url:
        logging.info("Removing temporary file '%s'", args.file)
        os.remove(args.file)