Ejemplo n.º 1
0
 def create_asset(self, release_id, asset):
     asset_name = os.path.basename(asset)
     url = self._UPLOADS_URL % (release_id, asset_name)
     # Our files are small enough to be loaded directly into memory.
     data = open(asset, 'rb').read()
     req = sanitized_Request(url, data)
     mime_type, _ = mimetypes.guess_type(asset_name)
     req.add_header('Content-Type', mime_type or 'application/octet-stream')
     return self._call(req)
Ejemplo n.º 2
0
 def create_release(self,
                    tag_name,
                    name=None,
                    body='',
                    draft=False,
                    prerelease=False):
     data = {
         'tag_name': tag_name,
         'target_commitish': 'master',
         'name': name,
         'body': body,
         'draft': draft,
         'prerelease': prerelease,
     }
     req = sanitized_Request(self._API_URL,
                             json.dumps(data).encode('utf-8'))
     return self._call(req)
Ejemplo n.º 3
0
 def _call(self, req):
     if isinstance(req, compat_basestring):
         req = sanitized_Request(req)
     req.add_header('Authorization', 'token %s' % self._token)
     response = self._opener.open(req).read().decode('utf-8')
     return json.loads(response)