コード例 #1
0
    def upload(self, name):
        if os.path.splitext(name)[-1] not in ['.xml', '.xpi', '.jar', '.zip']:
            name = name + '.xpi'

        v = json.dumps(dict(errors=0, warnings=1, notices=2, metadata={},
                            signing_summary={'trivial': 0, 'low': 0,
                                             'medium': 0, 'high': 0},
                            passed_auto_validation=1))
        fname = nfd_str(self.xpi_path(name))
        if not storage.exists(fname):
            with storage.open(fname, 'w') as fs:
                copyfileobj(open(fname), fs)
        d = dict(path=fname, name=name,
                 hash='sha256:%s' % name, validation=v)
        return FileUpload.objects.create(**d)
コード例 #2
0
ファイル: test_models.py プロジェクト: atsay/addons-server
    def upload(self, name):
        # Add in `.xpi` if the filename doesn't have a valid file extension.
        if os.path.splitext(name)[-1] not in EXTENSIONS:
            name = name + '.xpi'

        v = json.dumps(dict(errors=0, warnings=1, notices=2, metadata={},
                            signing_summary={'trivial': 0, 'low': 0,
                                             'medium': 0, 'high': 0},
                            passed_auto_validation=1))
        fname = nfd_str(self.xpi_path(name))
        if not storage.exists(fname):
            with storage.open(fname, 'w') as fs:
                copyfileobj(open(fname), fs)
        d = dict(path=fname, name=name,
                 hash='sha256:%s' % name, validation=v)
        return FileUpload.objects.create(**d)
コード例 #3
0
 def upload(self, name):
     validation_data = json.dumps({
         'errors': 0,
         'warnings': 1,
         'notices': 2,
         'metadata': {},
     })
     fname = nfd_str(self.xpi_path(name))
     if not storage.exists(fname):
         with storage.open(fname, 'w') as fs:
             shutil.copyfileobj(open(fname), fs)
     data = {
         'path': force_str(fname),
         'name': force_str(name),
         'hash': 'sha256:%s' % name,
         'validation': validation_data,
     }
     return FileUpload.objects.create(**data)
コード例 #4
0
    def upload(self, name):
        # Add in `.xpi` if the filename doesn't have a valid file extension.
        if os.path.splitext(name)[-1] not in EXTENSIONS:
            name = name + '.xpi'

        validation_data = json.dumps({
            'errors': 0,
            'warnings': 1,
            'notices': 2,
            'metadata': {},
        })
        fname = nfd_str(self.xpi_path(name))
        if not storage.exists(fname):
            with storage.open(fname, 'w') as fs:
                copyfileobj(open(fname), fs)
        data = {
            'path': fname,
            'name': name,
            'hash': 'sha256:%s' % name,
            'validation': validation_data
        }
        return FileUpload.objects.create(**data)
コード例 #5
0
ファイル: test_models.py プロジェクト: Natim/addons-server
    def upload(self, name):
        # Add in `.xpi` if the filename doesn't have a valid file extension.
        if os.path.splitext(name)[-1] not in EXTENSIONS:
            name = name + '.xpi'

        validation_data = json.dumps({
            'errors': 0,
            'warnings': 1,
            'notices': 2,
            'metadata': {},
        })
        fname = nfd_str(self.xpi_path(name))
        if not storage.exists(fname):
            with storage.open(fname, 'w') as fs:
                copyfileobj(open(fname), fs)
        data = {
            'path': fname,
            'name': name,
            'hash': 'sha256:%s' % name,
            'validation': validation_data
        }
        return FileUpload.objects.create(**data)