Skip to content

Commit c25babd

Browse files
committed
adding pylint and restart command
Signed-off-by: Vanessa Sochat <[email protected]>
1 parent a8558b4 commit c25babd

File tree

22 files changed

+694
-354
lines changed

22 files changed

+694
-354
lines changed

.pylintrc

Lines changed: 504 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Singularity Compose
22

33
This is a simple orchestration library for Singularity containers, akin to
4-
Docker Compose.
4+
Docker Compose.
5+
6+
## Examples
7+
8+
- [singularity-compose-simple](https://www.github.com/singularityhub/singularity-compose-simple): A single container example (working in full).
9+
- [singularity-compose-example](https://www.github.com/singularityhub/singularity-compose-example): The same application split into multiple containers, currently has issues because of Docker iptables edits (working on figuring out a solution).
510

6-
*under development*

scompose/client/__init__.py

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
2020
'''
2121

22-
from scompose.logger import bot
2322
import scompose
2423
import argparse
2524
import sys
@@ -31,7 +30,7 @@ def get_parser():
3130
parser = argparse.ArgumentParser(description="Singularity Compose")
3231

3332
# Verbosity
34-
parser.add_argument('--verbose', dest="verbose",
33+
parser.add_argument('--debug', dest="debug",
3534
help="use verbose logging to debug.",
3635
default=False, action='store_true')
3736

@@ -67,7 +66,7 @@ def get_parser():
6766
dest="command")
6867

6968
# print version and exit
70-
version = subparsers.add_parser("version",
69+
version = subparsers.add_parser("version", # pylint: disable=unused-variable
7170
help="show software version")
7271

7372

@@ -79,7 +78,7 @@ def get_parser():
7978

8079
# Config
8180

82-
config = subparsers.add_parser("config",
81+
config = subparsers.add_parser("config", # pylint: disable=unused-variable
8382
help="Validate and view the compose file")
8483

8584
# Create (assumes built already), Up (will also build, if able)
@@ -110,10 +109,6 @@ def get_parser():
110109
shell = subparsers.add_parser("shell",
111110
help="shell into an instance")
112111

113-
114-
kill = subparsers.add_parser("kill",
115-
help="kill instances")
116-
117112
# Logs
118113

119114
logs = subparsers.add_parser("logs",
@@ -127,33 +122,33 @@ def get_parser():
127122
help="clear existing logs.",
128123
default=False, action='store_true')
129124

130-
ps = subparsers.add_parser("ps",
125+
ps = subparsers.add_parser("ps", # pylint: disable=unused-variable
131126
help="list instances")
132127

133128
restart = subparsers.add_parser("restart",
134129
help="stop and start containers.")
135130

136131
# Add list of names
137-
for sub in [create, down, logs, up]:
132+
for sub in [build, create, down, logs, up, restart]:
138133
sub.add_argument('names', nargs="*",
139134
help='the names of the instances to target')
140135

141136
# Only one name allowed
142-
for sub in [shell, execute, kill]:
137+
for sub in [shell, execute]:
143138
sub.add_argument('name', nargs=1,
144139
help='the name of the instance to target')
145140

146141
return parser
147142

148143

149-
def main():
144+
def start():
150145
'''main is the entrypoint to singularity compose. We figure out the sub
151146
parser based on the command, and then import and call the appropriate
152147
main.
153148
'''
154149
parser = get_parser()
155150

156-
def help(return_code=0):
151+
def show_help(return_code=0):
157152
'''print help, including the software version and exit with return code
158153
'''
159154
version = scompose.__version__
@@ -164,34 +159,46 @@ def help(return_code=0):
164159

165160
# If the user didn't provide any arguments, show the full help
166161
if len(sys.argv) == 1:
167-
help()
162+
show_help()
168163
try:
169164
args, extra = parser.parse_known_args()
170165
except:
171166
sys.exit(0)
172167

173-
if args.verbose is False:
168+
if args.debug is True:
174169
os.environ['MESSAGELEVEL'] = "DEBUG"
175170
else:
176171
os.environ['MESSAGELEVEL'] = args.log_level
177172

173+
# Import the logger to grab verbosity level
174+
from scompose.logger import bot
175+
178176
# Show the version and exit
179177
if args.command == "version" or args.version is True:
180178
print(scompose.__version__)
181179
sys.exit(0)
182180

183181
# Does the user want a shell?
184-
if args.command == "build": from .build import main
185-
elif args.command == "create": from .create import main
186-
elif args.command == "config": from .config import main
187-
elif args.command == "down": from .down import main
188-
elif args.command == "exec": from .exec import main
189-
elif args.command == "kill": from .kill import main
190-
elif args.command == "logs": from .logs import main
191-
elif args.command == "ps": from .ps import main
192-
elif args.command == "restart": from .restart import main
193-
elif args.command == "shell": from .shell import main
194-
elif args.command == "up": from .up import main
182+
if args.command == "build":
183+
from .build import main
184+
elif args.command == "create":
185+
from .create import main
186+
elif args.command == "config":
187+
from .config import main
188+
elif args.command == "down":
189+
from .down import main
190+
elif args.command == "exec":
191+
from .exec import main
192+
elif args.command == "logs":
193+
from .logs import main
194+
elif args.command == "ps":
195+
from .ps import main
196+
elif args.command == "restart":
197+
from .restart import main
198+
elif args.command == "shell":
199+
from .shell import main
200+
elif args.command == "up":
201+
from .up import main
195202

196203
# Pass on to the correct parser
197204
return_code = 0
@@ -206,4 +213,4 @@ def help(return_code=0):
206213
sys.exit(return_code)
207214

208215
if __name__ == '__main__':
209-
main()
216+
start()

scompose/client/build.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@
1818
'''
1919

2020
from scompose.project import Project
21-
import logging
22-
import json
23-
import sys
24-
import os
25-
26-
27-
28-
log = logging.getLogger(__name__)
2921

3022
def main(args, parser, extra):
3123
'''Build or rebuild containers
@@ -40,4 +32,4 @@ def main(args, parser, extra):
4032
env_file=args.env_file)
4133

4234
# Builds any containers into folders
43-
project.build()
35+
project.build(args.names)

scompose/client/config.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,8 @@
1818
'''
1919

2020
from scompose.project import Project
21-
import logging
22-
import json
23-
import sys
2421
import os
2522

26-
27-
log = logging.getLogger(__name__)
28-
2923
def main(args, parser, extra):
3024
'''View or validate a configuration file
3125
@@ -39,7 +33,6 @@ def main(args, parser, extra):
3933
# Initialize the project
4034
project = Project(filename=args.file,
4135
name=args.project_name,
42-
working_dir=working_dir,
4336
env_file=args.env_file)
4437

4538
# Builds any containers into folders

scompose/client/create.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@
1818
'''
1919

2020
from scompose.project import Project
21-
import logging
22-
import json
23-
import sys
24-
import os
25-
26-
27-
log = logging.getLogger(__name__)
2821

2922
def main(args, parser, extra):
3023
'''create one or more instances. If they don't exist, build first.

scompose/client/down.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@
1818
'''
1919

2020
from scompose.project import Project
21-
import logging
22-
import json
23-
import sys
24-
import os
25-
26-
27-
log = logging.getLogger(__name__)
2821

2922
def main(args, parser, extra):
3023
'''bring one or more instances down

scompose/client/exec.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@
1818
'''
1919

2020
from scompose.project import Project
21-
import logging
22-
import json
23-
import sys
24-
import os
25-
26-
27-
log = logging.getLogger(__name__)
2821

2922
def main(args, parser, extra):
3023
'''execute a command to an instance.

scompose/client/logs.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@
1818
'''
1919

2020
from scompose.project import Project
21-
import logging
22-
import json
23-
import sys
24-
import os
25-
26-
27-
log = logging.getLogger(__name__)
2821

2922
def main(args, parser, extra):
3023
'''bring one or more instances down

scompose/client/ps.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@
1818
'''
1919

2020
from scompose.project import Project
21-
import logging
22-
import json
23-
import sys
24-
import os
25-
26-
27-
log = logging.getLogger(__name__)
2821

2922
def main(args, parser, extra):
3023
'''bring one or more instances down

0 commit comments

Comments
 (0)