Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 139cb9ff authored by Maude Le Jeune's avatar Maude Le Jeune
Browse files

Feature #850 script in place, missing main and seg files

parent ae65b320
......@@ -30,6 +30,7 @@ from pipelet.repository import LocalRepository
from contextlib import closing
import pickle
import os
current_dir = os.path.dirname(os.path.abspath(__file__))
def flatten(seq):
"""
......@@ -213,6 +214,54 @@ def reduced_code_formatting(s, unsafe=False):
min_code += l+'\n'
return min_code
def create_pipe(pipename, prefix=[]):
""" Create an empty pipe environment including main, defaulf
segment, prefix and log directories.
This function is called from the script pipeutils.
Parameters
----------
pipename: string, pipe name
prefix: string, pipe prefix.
"""
import os
import shutil
## make code dir
code_dir = os.path.join("./"+pipename)
if not os.path.exists(code_dir):
os.mkdir(code_dir)
## make prefix and log dir
if prefix:
if not os.path.exists(prefix):
os.mkdir(prefix)
else:
prefix = code_dir
logdir = os.path.join(prefix, "log")
if not os.path.exists(logdir):
os.mkdir(logdir)
if not os.path.exists(os.path.join(code_dir, "main.py")):
shutil.copy(current_dir+"/static/main.py", code_dir) ## make a main file with some doc
if not os.path.exists(os.path.join(code_dir, "seg_default_code.py")):
shutil.copy(current_dir+"/static/seg_default_code.py", code_dir) ## make a segment file with some doc
print "\n\n-----------------------------------------------------------"
print " Pipeline '%s' has been successfully created "%pipename
print "-----------------------------------------------------------\n\n"
print "1- Change directory to '%s' to set your pipeline scheme\n in the file named 'main.py'\n"%code_dir
print "2- Rename and edit the 'seg_default_code.py' to set the segments content.\n"
print "3- Run 'python main.py -d' to enter the debugging execution mode."
print "Type 'python main.py --help' to get the full list of options.\n"
print "4- Run 'pipeweb track %s %s/.sqlstatus' \n to add the pipe to the web interface.\n"%(pipename, prefix)
print "5- Set acl with 'pipeutils -a username -l 2 %s/.sqlstatus'\n"%prefix
print "6- Launch the web server with 'pipeweb start'"
print "You should be able to browse the result on the web page http://localhost:8080\n"
print "Retype the current command line to get those instructions back."
def hash_file(codefile):
"""Use cheksum algorithm to return a unique key for file.
......
......@@ -2,7 +2,11 @@
def main():
import optparse
parser = optparse.OptionParser(usage="\nTo activate acl and setup a new user:\n %prog -a <username> [-l <access_level>] <sql_file>\nTo suppress an existing user:\n %prog -d <username> ")
parser = optparse.OptionParser(usage="\nTo create a new pipeline:\n %prog -c <pipename> [-p <prefix>]\nTo activate acl and setup a new user:\n %prog -a <username> [-l <access_level>] <sql_file>\nTo suppress an existing user:\n %prog -d <username> ")
parser.add_option('-c', '--create-pipeline',
help='Create a new pipeline',)
parser.add_option('-p', '--prefix',
help='Prefix of the pipeline',)
parser.add_option('-a', '--add-user',
help='Setup acl, add a new user',)
parser.add_option('-d', '--del-user',
......@@ -12,7 +16,7 @@ def main():
(options, args) = parser.parse_args()
if len(args) < 1:
if len(args) < 0:
parser.print_usage()
exit(-1)
......@@ -30,5 +34,10 @@ def main():
elif options.del_user:
auth.del_user(args[0], options.del_user)
elif options.create_pipeline:
from pipelet import utils
utils.create_pipe(options.create_pipeline, prefix=options.prefix)
if __name__ == "__main__":
main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment