#!/usr/bin/python # token_update (name|@file) ("data"|@file|-) [password] import sys import urllib2 import getpass import ts_lib import ts_cnf import ts_msg CMD_ADD = "add" CMD_LAST = "last" if len(sys.argv) < 4: msg = ts_msg.get_msg("msg_usg", sys.argv[0], "help_tok", "help_data", "help_pwd") print msg quit() if sys.argv[1][0] == "@": file_name = sys.argv[1][1:] dn_or_raw = ts_lib.get_data_from_file(file_name) msg = "" if dn_or_raw["exitcode"] == 4: msg = ts_msg.get_msg("msg_err", "file_rerr", file_name) if dn_or_raw["exitcode"] == 3: msg = ts_msg.get_msg("msg_err", "file_miss", file_name) if dn_or_raw["exitcode"] == 2: msg = ts_msg.get_msg("msg_err", "file_empt", file_name)
#!/usr/bin/python # token_create (name|@file) [password|-] import sys import urllib2 import getpass import ts_lib import ts_cnf import ts_msg CMD = "z" if len(sys.argv) < 3: msg = ts_msg.get_msg("msg_usg", sys.argv[0], "help_tok", "help_pwd") print msg quit() if sys.argv[1][0] == "@": file_name = sys.argv[1][1:] dn_or_raw = ts_lib.get_data_from_file(file_name) msg = "" e = dn_or_raw["exitcode"] if e == 4: msg = ts_msg.get_msg("msg_err", "file_rerr", file_name) if e == 3: msg = ts_msg.get_msg("msg_err", "file_miss", file_name) if e == 2: msg = ts_msg.get_msg("msg_err", "file_empt", file_name)
#!/usr/bin/python # job_id_check (jobId) import sys import urllib2 import getpass import ts_lib import ts_cnf import ts_msg CMD = "job" if len(sys.argv) < 2: msg = ts_msg.get_msg("msg_usg", sys.argv[0], "help_jid") print msg quit() if int(sys.argv[1]) >= 1000: jid = sys.argv[1] else: msg = ts_msg.get_msg("msg_err", "job_err") print msg quit() http_rqst = ts_lib.get_spaced_concat(CMD, jid) try: http_resp = urllib2.urlopen( "http://{}:{}/{}".format(ts_cnf.HOST, ts_cnf.PORT, http_rqst) ).read()
# 3 No data # =========== # my data # =========== import sys import urllib2 import getpass import ts_lib import ts_cnf import ts_msg CMD = "last" if len(sys.argv) < 3: msg = ts_msg.get_msg("msg_usg", sys.argv[0], "help_tok", "help_pwd") print msg quit() if sys.argv[1][0] == "@": file_name = sys.argv[1][1:] dn_or_raw = ts_lib.get_data_from_file(file_name) msg = "" if dn_or_raw["exitcode"] == 4: msg = ts_msg.get_msg("msg_err", "file_rerr", file_name) if dn_or_raw["exitcode"] == 3: msg = ts_msg.get_msg("msg_err", "file_miss", file_name) if dn_or_raw["exitcode"] == 2: msg = ts_msg.get_msg("msg_err", "file_empt", file_name)
#!/usr/bin/python # token_send (name|@file) (instant|onhold|release) [password|-] # output: keys import sys import urllib2 import getpass import ts_lib import ts_cnf import ts_msg CMD_LAST = "last" if len(sys.argv) < 4: msg = ts_msg.get_msg("msg_usg", sys.argv[0], "help_tok", "help_meth", "help_pwd") print msg quit() if sys.argv[1][0] == "@": file_name = sys.argv[1][1:] dn_or_raw = ts_lib.get_data_from_file(file_name) msg = "" if dn_or_raw["exitcode"] == 4: msg = ts_msg.get_msg("msg_err", "file_rerr", file_name) if dn_or_raw["exitcode"] == 3: msg = ts_msg.get_msg("msg_err", "file_miss", file_name) if dn_or_raw["exitcode"] == 2: msg = ts_msg.get_msg("msg_err", "file_empt", file_name)
#!/usr/bin/python # token_receive (name|@file) ("keys"|@file|-) [password|-] import sys import urllib2 import getpass import ts_lib import ts_cnf import ts_msg CMD_ADD = "add" CMD_LAST = "last" if len(sys.argv) < 4: msg = ts_msg.get_msg("msg_usg", sys.argv[0], "help_tok", "help_keys", "help_pwd") print msg quit() if sys.argv[1][0] == "@": file_name = sys.argv[1][1:] dn_or_raw = ts_lib.get_data_from_file(file_name) msg = "" if dn_or_raw["exitcode"] == 4: msg = ts_msg.get_msg("msg_err", "file_rerr", file_name) if dn_or_raw["exitcode"] == 3: msg = ts_msg.get_msg("msg_err", "file_miss", file_name) if dn_or_raw["exitcode"] == 2: msg = ts_msg.get_msg("msg_err", "file_empt", file_name) if dn_or_raw["exitcode"] == 1: