Implement spoc-app list running|stopped, closes #5
This commit is contained in:
parent
659992d249
commit
7a07d563e9
@ -9,6 +9,7 @@ from spoc import repo_local, repo_online, repo_publish
|
||||
from spoc.app import App
|
||||
from spoc.cli import ActionQueue, print_lock, readable_size
|
||||
from spoc.config import LOCK_FILE
|
||||
from spoc.container import ContainerState
|
||||
from spoc.flock import locked
|
||||
from spoc.image import Image
|
||||
|
||||
@ -23,6 +24,22 @@ def listing(list_type):
|
||||
apps = [a for a,d in repo_local.get_apps().items() if a in online_apps and parse_version(online_apps[a]['version']) > parse_version(d['version'])]
|
||||
elif list_type == 'published':
|
||||
apps = repo_publish.get_apps()
|
||||
elif list_type == 'running':
|
||||
apps = []
|
||||
for app in repo_local.get_apps():
|
||||
app = App(app)
|
||||
for container in app.containers:
|
||||
if container.get_state() == ContainerState.RUNNING:
|
||||
apps.append(app.name)
|
||||
break
|
||||
elif list_type == 'stopped':
|
||||
apps = list(repo_local.get_apps())
|
||||
for app in repo_local.get_apps():
|
||||
app = App(app)
|
||||
for container in app.containers:
|
||||
if container.get_state() == ContainerState.RUNNING:
|
||||
apps.remove(app.name)
|
||||
break
|
||||
for app in apps:
|
||||
print(app)
|
||||
|
||||
@ -119,7 +136,7 @@ subparsers = parser.add_subparsers()
|
||||
|
||||
parser_list = subparsers.add_parser('list')
|
||||
parser_list.set_defaults(action=listing)
|
||||
parser_list.add_argument('type', choices=('installed', 'online', 'updates', 'published'), default='installed', const='installed', nargs='?')
|
||||
parser_list.add_argument('type', choices=('installed', 'online', 'updates', 'published', 'running', 'stopped'), default='installed', const='installed', nargs='?')
|
||||
|
||||
parser_install = subparsers.add_parser('install')
|
||||
parser_install.set_defaults(action=install)
|
||||
|
Loading…
Reference in New Issue
Block a user