コード例 #1
0
 def create(cls, request, version, hashedID, packagename, filename):
   upload = Upload(device=Device.create(hashedID), version=version, received_time=now(),
                   packagename=packagename, upload_filename=filename)
   
   content = util.unzip_stream(request).read().decode('utf-8', errors='ignore')
   upload.bytes = len(content)
   
   if os.path.exists(upload.filename):
     raise BackendValidationError("upload file already exists")
   else:
     util.stream_to_file(StringIO.StringIO(content), upload.filename)
   
   try:
     upload.full_clean()
     upload.compress(save=False)
   except:
     do_remove_linked_file(upload.filename, upload.basedir())
     raise
   
   return upload
コード例 #2
0
    def create(cls, request, version, hashedID, packagename, filename):
        upload = Upload(device=Device.create(hashedID),
                        version=version,
                        received_time=now(),
                        packagename=packagename,
                        upload_filename=filename)

        content = util.unzip_stream(request).read().decode('utf-8',
                                                           errors='ignore')
        upload.bytes = len(content)

        if os.path.exists(upload.filename):
            raise BackendValidationError("upload file already exists")
        else:
            util.stream_to_file(StringIO.StringIO(content), upload.filename)

        try:
            upload.full_clean()
            upload.compress(save=False)
        except:
            do_remove_linked_file(upload.filename, upload.basedir())
            raise

        return upload
コード例 #3
0
def write_canonical_xml(root, filename, mode=0440):  
  xml_string = StringIO.StringIO()
  etree.ElementTree(root).write_c14n(xml_string)
  util.stream_to_file(xml_string, filename, compressed=True)
コード例 #4
0
def write_canonical_xml(root, filename, mode=0440):
    xml_string = StringIO.StringIO()
    etree.ElementTree(root).write_c14n(xml_string)
    util.stream_to_file(xml_string, filename, compressed=True)