Esempio n. 1
0
    def handle(self, *args, **options):
        if len(args) < 5:
            raise CommandError('Usage: add_file /base/path program version type file...')

        release = Release.objects.get(program = args[1], version = args[2])

        dlpath = args[0]

        while dlpath[-1] == '/':
            dlpath = dlpath[:-1]

        for f in args[4:]:
            print "Adding %s..." % f
            path, filename = os.path.split(f)

            data = open(f).read()

            dl = Download()
            dl.release = release

            md5 = hashlib.md5()
            md5.update(data)
            dl.md5 = md5.hexdigest()

            sha1 = hashlib.sha1()
            sha1.update(data)
            dl.sha1 = sha1.hexdigest()

            dl.size = len(data)

            dl.platform = args[3]

            dl.location = '%s/%s' % (dlpath, filename)

            dl.save()
Esempio n. 2
0
    def handle(self, *args, **options):

        release = Release.objects.get(program=options['program'], version=options['version'])

        dlpath = options['base']

        while dlpath[-1] == '/':
            dlpath = dlpath[:-1]

        for f in options['file']:
            self.stdout.write("Adding %s..." % f)
            filename = os.path.basename(f)

            data = open(f).read()

            dl = Download()
            dl.release = release

            md5 = hashlib.md5()
            md5.update(data)
            dl.md5 = md5.hexdigest()

            sha1 = hashlib.sha1()
            sha1.update(data)
            dl.sha1 = sha1.hexdigest()

            dl.size = len(data)

            dl.platform = options['type']

            dl.location = '%s/%s' % (dlpath, filename)

            dl.save()
Esempio n. 3
0
    def handle(self, *args, **options):

        release = Release.objects.get(program=options['program'],
                                      version=options['version'])

        dlpath = options['base']

        while dlpath[-1] == '/':
            dlpath = dlpath[:-1]

        for f in options['file']:
            self.stdout.write("Adding %s..." % f)
            filename = os.path.basename(f)

            with open(f, 'rb') as handle:
                data = handle.read()

            dl = Download()
            dl.release = release

            md5 = hashlib.md5()
            md5.update(data)
            dl.md5 = md5.hexdigest()

            sha1 = hashlib.sha1()
            sha1.update(data)
            dl.sha1 = sha1.hexdigest()

            sha256 = hashlib.sha256()
            sha256.update(data)
            dl.sha256 = sha256.hexdigest()

            dl.size = len(data)

            dl.platform = options['type']

            dl.location = '%s/%s' % (dlpath, filename)

            dl.save()
Esempio n. 4
0
    def handle(self, *args, **options):

        release = Release.objects.get(program=options["program"],
                                      version=options["version"])

        dlpath = options["base"]

        while dlpath[-1] == "/":
            dlpath = dlpath[:-1]

        for f in options["file"]:
            self.stdout.write("Adding %s..." % f)
            filename = os.path.basename(f)

            with open(f, "rb") as handle:
                data = handle.read()

            dl = Download()
            dl.release = release

            md5 = hashlib.md5()
            md5.update(data)
            dl.md5 = md5.hexdigest()

            sha1 = hashlib.sha1()
            sha1.update(data)
            dl.sha1 = sha1.hexdigest()

            sha256 = hashlib.sha256()
            sha256.update(data)
            dl.sha256 = sha256.hexdigest()

            dl.size = len(data)

            dl.platform = options["type"]

            dl.location = f"{dlpath}/{filename}"

            dl.save()
Esempio n. 5
0
    def handle(self, *args, **options):
        if len(args) < 5:
            raise CommandError(
                'Usage: add_file /base/path program version type file...')

        release = Release.objects.get(program=args[1], version=args[2])

        dlpath = args[0]

        while dlpath[-1] == '/':
            dlpath = dlpath[:-1]

        for f in args[4:]:
            self.stdout.write("Adding %s..." % f)
            filename = os.path.basename(f)

            data = open(f).read()

            dl = Download()
            dl.release = release

            md5 = hashlib.md5()
            md5.update(data)
            dl.md5 = md5.hexdigest()

            sha1 = hashlib.sha1()
            sha1.update(data)
            dl.sha1 = sha1.hexdigest()

            dl.size = len(data)

            dl.platform = args[3]

            dl.location = '%s/%s' % (dlpath, filename)

            dl.save()
Esempio n. 6
0
dlpath = sys.argv[1]

while dlpath[-1] == '/':
    dlpath = dlpath[:-1]

for f in sys.argv[5:]:
    print "Adding %s..." % f
    path, filename = os.path.split(f)

    data = open(f).read()

    dl = Download()
    dl.release = release

    md5 = hashlib.md5()
    md5.update(data)
    dl.md5 = md5.hexdigest()

    sha1 = hashlib.sha1()
    sha1.update(data)
    dl.sha1 = sha1.hexdigest()

    dl.size = len(data)

    dl.platform = sys.argv[4]

    dl.location = '%s/%s' % (dlpath, filename)

    dl.save()