-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathubuntu.py
More file actions
executable file
·37 lines (30 loc) · 1.06 KB
/
Copy pathubuntu.py
File metadata and controls
executable file
·37 lines (30 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
import os
import sys
from string import Template
IMAGE = 'cbpodd/ubuntu:20.04'
CC = 'zsh'
def main():
commandArray = list()
commandArray.append("docker run --rm -it") # Command and some parameters
# commandArray.append("--net=none") # More parameters
pwdTemplate = Template('-v $PWD:/root/repos') # Present working directory
commandArray.append(pwdTemplate.substitute(PWD=getpwd()))
commandArray.append(IMAGE) # Pull the requested docker image
commandArray.append(CC) # Pass in chosen latex compiler
commandArray.extend(sys.argv[1:]) # command line arguments passed into compiler
# Run the command
return os.system(' '.join(commandArray))
def getpwd():
cwd = os.getcwd()
if sys.platform.startswith('win32'):
cwdArray = cwd.split('\\')
outArray = ['/']
driveLetter = cwdArray[0][0].lower()
outArray.append(driveLetter)
outArray.extend(cwdArray[1:])
return '/'.join(outArray)
return cwd
if __name__ == "__main__":
exit_code = main()
sys.exit(exit_code)