Skip to content

Instantly share code, notes, and snippets.

@benguillet benguillet/gist:5190447
Last active Dec 15, 2015

What would you like to do?
A Django gist to send a text file and launch a program on a different server
if request.method == 'POST':
if form.is_valid():
# write file in ~/hipercic/apps/dcor/jobs/
with open('apps/dcor/jobs/job_' +"%Y%m%d_%H%M%S") + '_params.txt', 'w') as params_file:
for key, val in form.cleaned_data.iteritems():
params_file.write(str(val) + ' \n')
scp = 'scp /home/guillet/hipercic/' + + ''
context['scp'] = scp
return_code_scp =, shell=True)
context['return_code_scp'] = return_code_scp
head, tail = os.path.split(
print tail
cpp = 'ssh "cd dcor; ./test jobs/' + tail + '"'
context['cpp'] = cpp
return_code_cpp =, shell=True)
context['return_code_cpp'] = return_code_cpp
return render(request, 'base_pending.html', context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.