You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.3 KiB
Python

"""
"""
import smart
import sys
import json
import pandas as pd
import numpy as np
from multiprocessing import Process
SYS_ARGS = {}
if len(sys.argv) > 1:
N = len(sys.argv)
for i in range(1,N):
value = None
if sys.argv[i].startswith('--'):
key = sys.argv[i][2:] #.replace('-','')
SYS_ARGS[key] = 1
if i + 1 < N:
value = sys.argv[i + 1] = sys.argv[i+1].strip()
if key and value:
SYS_ARGS[key] = value
i += 2
#
# Let's determine what data to return ...
# --folder <name> and/or --app <names>
def format(prefix,pointer,logger,container):
return [{'args':{prefix:term.strip(),'logger':logger},'pointer':pointer} for term in container]
folders = format('path',smart.folder.read,smart.logger.log,SYS_ARGS['folders'].split(',')) if 'folders' in SYS_ARGS else []
apps = format('name',smart.top.read,smart.logger.log,SYS_ARGS['apps'].split(',')) if 'apps' in SYS_ARGS else []
if 'cols' in SYS_ARGS :
cols = [name.strip() for name in SYS_ARGS['cols'].split(',')]
else:
cols = []
nodes = folders + apps
for node in nodes :
if cols :
node['args']['cols'] = cols
pthread = Process(target=node['pointer'],args=(node['args'],))
pthread.start()