diff --git a/tes/__init__.py b/tes/__init__.py index 72945844e9fa8d8a855aa64606a309e283d8f2e4..3c4ee04ab77b21fdbdb223b0690aa5efe8cb1f3f 100644 --- a/tes/__init__.py +++ b/tes/__init__.py @@ -5,11 +5,11 @@ from flask_cors import CORS, cross_origin from .tunnelstat import SSHSession app = Flask(__name__) -app.config['LOCAL_DEV'] = True +app.config['LOCAL_DEV'] = False app.config['DEBUG'] = True app.config['SECRET_KEY'] = 'asdasfdfj' import datetime -app.config['PERMANENT_SESSION_LIFETIME'] = datetime.timedelta(seconds=30) +app.config['PERMANENT_SESSION_LIFETIME'] = datetime.timedelta(seconds=300) app.config['SESSION_REFRESH_EACH_REQUEST'] = True app.config['SESSION_COOKIE_NAME'] = 'tessession' app.config['TWSPROXY'] = 'http://localhost:4000/' @@ -27,9 +27,7 @@ from . import apiendpoints def after_cleanup_sessions(response): import logging logger=logging.getLogger() - logger.debug("in after_cleanup_sessions") sshsessid = session.get('sshsessid', None) - print("the sshsessid for this request was {}".format(sshsessid)) # kvsessionextension.cleanup_sessions(app) _ttl = app.config['PERMANENT_SESSION_LIFETIME'] @@ -39,7 +37,7 @@ def after_cleanup_sessions(response): ttl = _ttl for k, sshsess in list(sshsessions.items()): if datetime.datetime.now() > sshsess.last + ttl: - print("session last seen at {} now {}".format(sshsess.last,datetime.datetime.now())) + logger.debug("session last seen at {} now {}".format(sshsess.last,datetime.datetime.now())) sshsess.kill() del sshsessions[k] return response diff --git a/tes/apiendpoints.py b/tes/apiendpoints.py index 2fd06c4004256724b934377cc936033c3109b436..b7aad9f388d0379265454a71ba8fbfc08b4e5e7c 100644 --- a/tes/apiendpoints.py +++ b/tes/apiendpoints.py @@ -45,6 +45,9 @@ class GetCert(Resource): resp = sess.post(url, json=data, headers=headers, verify=False) print("get_cert returned from its external call") data = resp.json() + import logging + logger = logging.getLogger() + logger.debug('attempted get_cert {}'.format(data)) return data['certificate'] class TestAuth(Resource): @@ -224,13 +227,18 @@ class JobSubmit(Resource): """ def post(self): """starting a job is a post, since it changes the state of the backend""" + import logging + logger=logging.getLogger() params = get_conn_params() + logger.debug('submitting with parameters {}'.format(params)) sshsess = SSHSession.get_sshsession() res = Ssh.execute(sshsess, host=params['identity']['site']['host'], user=params['identity']['username'], cmd=params['interface']['submitcmd'], stdin=params['app']['startscript']) if not (res['stderr'] == '' or res['stderr'] is None or res['stderr'] == b''): print(res['stderr']) + logger.debug(res['stderr']) flask_restful.abort(400, message=res['stderr'].decode()) + logger.debug(res['stdout']) return res['stdout'].decode() def gen_authtok():