Skip to content

Commit

Permalink
Send generator-package array as json-array to the build server - (Sol…
Browse files Browse the repository at this point in the history
…ves- #397)  (#399)

* Sending generator package array to the build server

* Sending the JSOn array straight to the build server

* Replaced packages with recipe
  • Loading branch information
Pranav Kulshrestha authored and tabesin committed Feb 13, 2019
1 parent 81e0a35 commit e69bfcb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app.py
Expand Up @@ -96,7 +96,7 @@ def index():
for name, value in request.form.items():
if name.startswith("GENERATOR_"):
variables[name] = value
features = json.dumps(variables, ensure_ascii=False)
recipe = json.dumps(variables, ensure_ascii=False) # Dumping the generator-packages into a JSON array
wallpaper = request.files["desktop-wallpaper"]
upload_wallpaper(wallpaper)
logo = request.files["desktop-logo"]
Expand All @@ -108,7 +108,7 @@ def index():
TRAVIS_TAG = urlify(TRAVIS_TAG) # this will fix url issue
os.environ["TRAVIS_TAG"] = TRAVIS_TAG
os.environ["event_url"] = event_url
os.environ["features"] = features
os.environ["recipe"] = recipe
with open('travis_script_1.sh', 'rb') as f:
os.environ["TRAVIS_SCRIPT"] = str(base64.b64encode(f.read()))[1:]
return redirect(url_for('output'))
Expand All @@ -119,7 +119,7 @@ def index():
def output():
if flag:
if os.environ['TRAVIS_TAG']: # if TRAVIS_TAG have value it will proceed
build.send_trigger_request(os.environ['email'], os.environ['TRAVIS_TAG'], os.environ['event_url'],os.environ['TRAVIS_SCRIPT'])
build.send_trigger_request(os.environ['email'], os.environ['TRAVIS_TAG'], os.environ['event_url'],os.environ['TRAVIS_SCRIPT'], os.environ['recipe'])
print ('/build called')
return render_template('build.html')
else:
Expand Down
3 changes: 2 additions & 1 deletion build.py
Expand Up @@ -3,7 +3,7 @@
import os
import requests

def send_trigger_request(email, TRAVIS_TAG, event_url, TRAVIS_SCRIPT):
def send_trigger_request(email, TRAVIS_TAG, event_url, TRAVIS_SCRIPT, recipe):
USER = 'fossasia'
PROJECT = 'meilix'
BRANCH = 'master'
Expand All @@ -17,6 +17,7 @@ def send_trigger_request(email, TRAVIS_TAG, event_url, TRAVIS_SCRIPT):
request['config']['env']['TRAVIS_TAG'] = TRAVIS_TAG
request['config']['env']['event_url'] = event_url
request['config']['env']['TRAVIS_SCRIPT'] = TRAVIS_SCRIPT
request['config']['env']['recipe'] = recipe
request_body['request'] = request
request_body = json.dumps(request_body)
headers = { "Content-Type": "application/json", "Accept": "application/json", "Travis-API-Version": "3", "Authorization": "token {}".format(os.environ.get('KEY', None))}
Expand Down

0 comments on commit e69bfcb

Please sign in to comment.