Skip to content

Commit

Permalink
Fix oauth_token
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jun 16, 2016
1 parent 758d756 commit 2b4f3eb
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions scripts/release_db_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,36 @@
from subprocess import call

# Exit if we are not on origin/master
if os.environ['TRAVIS_SECURE_ENV_VARS'] != 'true' or os.environ['TRAVIS_BRANCH'] != 'master':
return
if os.environ['TRAVIS_SECURE_ENV_VARS'] == 'true' and os.environ['TRAVIS_BRANCH'] == 'master':
with open('/tmp/template_db.dump', 'w') as f:
call(['pg_dump', '-n', '"qgep"', '-Fc', 'qgep'], stdout=f)

with open('/tmp/template_db.dump', 'w') as f:
call(['pg_dump', '-n', '"qgep"', '-Fc', 'qgep'], stdout=f)
# Release name based on date/time
releasename=time.strftime("%Y%m%d-%H%M%S")

# Release name based on date/time
releasename=time.strftime("%Y%m%d-%H%M%S")
# Create a release
conn = httplib.HTTPSConnection('api.github.com')
headers = {
'User-Agent' : 'Deploy-Script',
'Authorization': 'token {}'.format(os.environ['OAUTH_TOKEN'])
}
data = json.dumps({"tag_name": releasename})

# Create a release
conn = httplib.HTTPSConnection('api.github.com')
headers = {
'User-Agent' : 'Deploy-Script',
'Authorization': 'token {}'.format(os.environ['OAUTH'])
}
data = json.dumps({"tag_name": releasename})
conn.request('POST', '/repos/QGEP/datamodel/releases', body=data, headers=headers)

conn.request('POST', '/repos/QGEP/datamodel/releases', body=data, headers=headers)
response = conn.getresponse()

response = conn.getresponse()
release = json.load(response)

release = json.load(response)
print release

print release

conn = httplib.HTTPSConnection('uploads.github.com')
headers['Content-Type'] = 'application/zip'
url='{}?name={}'.format(release['upload_url'][:-13], 'template_db.dump')
print 'Upload to ' + url

conn = httplib.HTTPSConnection('uploads.github.com')
headers['Content-Type'] = 'application/zip'
url='{}?name={}'.format(release['upload_url'][:-13], 'template_db.dump')
print 'Upload to ' + url
with open('/tmp/template_db.dump', 'r') as f:
conn.request('POST', url, f, headers)

with open('/tmp/template_db.dump', 'r') as f:
conn.request('POST', url, f, headers)

print conn.getresponse().read()
print conn.getresponse().read()

0 comments on commit 2b4f3eb

Please sign in to comment.