Skip to content
Snippets Groups Projects
Commit 4f770a63 authored by Yohan Jarosz's avatar Yohan Jarosz
Browse files

fix user issue

parent 1c28f624
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ from lib.docopt import docopt
from lib.path import Path
import subprocess
import os
import getpass
import json
import shlex
from copy import deepcopy
......@@ -68,6 +69,12 @@ def yes_or_no(question):
return yes_or_no("Please enter ")
def format_command(cmd, dir):
# get group id and username of the user
username = getpass.getuser()
return ' /bin/bash -c "{c} ; useradd {u} && chown -R {u} {d} && chmod 755 {d}"'.format(c=cmd, u=username, d=dir)
def init(args):
CURRENT_PATH = Path(__file__).parent.abspath()
# start docker container to index files and setup prokka
......@@ -76,10 +83,11 @@ def init(args):
cmd = [
'docker', 'run', '--rm',
'-v %s:/code' % CURRENT_PATH,
'-v %s:/databases' % db_path, container_name, 'snakemake -s /code/init.rule'
'-v %s:/databases' % db_path, container_name
]
print("Executing", '"', ' '.join(cmd), '"')
subprocess.call(shlex.split(' '.join(cmd)))
cmd = ' '.join(cmd) + format_command('snakemake -s /code/init.rule', '/databases')
print("Executing", '"', cmd, '"')
subprocess.call(cmd, shell=True)
def run(args):
......@@ -136,14 +144,15 @@ def run(args):
if args['--enter']:
cmd += ['-it']
# add container name and commands to pass to snakemake
cmd += [container_name] + args['COMMANDS']
cmd += [container_name]
# if --enter flag is specified, change the command
if args['--enter']:
cmd += ['/bin/bash']
# parse CL correctly
cmd = shlex.split(' '.join(cmd))
print("Executing", '"', ' '.join(cmd), '"')
subprocess.call(cmd)
cmd = ' '.join(cmd) + format_command(' '.join(args['COMMANDS']), '/output')
print("Executing", '"', cmd, '"')
subprocess.call(cmd, shell=True)
def validate(args):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment