Exemplo n.º 1
0
def main():

    parser = ArgumentParser(prog="tm hashconf")
    parser.add_argument("conf_file", help="The configuration file")

    args = parser.parse_args()

    conf_file = {}
    with open(args.conf_file, "r") as inf:
        exec inf in conf_file
    print mac(conf_file["SECRET_KEY"], conf_file["TAR_DATA"], sha256).hexdigest()
Exemplo n.º 2
0
def main():

	parser = ArgumentParser( prog = 'tm hashconf' )
	parser.add_argument( 'conf_file', help = 'The configuration file' )

	args = parser.parse_args()

	conf_file = {}
	with open( args.conf_file, 'r' ) as inf:
		exec inf in conf_file
	print mac( conf_file[ 'SECRET_KEY' ], conf_file[ 'TAR_DATA' ], sha256 ).hexdigest()
Exemplo n.º 3
0
def _sign( uid ):
	return '{0}:{1}'.format( uid, mac( app.config[ 'SECRET_KEY' ], uid, sha256 ).hexdigest() )
Exemplo n.º 4
0
# get confs
app = Flask( __name__ )
try:
	app.config.from_envvar( 'TM_SETTINGS' )
except:
	exit( 'Error loading TM_SETTINGS, is such variable defined?' )

# setup the loader so that if finds the templates also in the zip file
app.jinja_loader = PackageLoader( 'tm', 'client' )

# make UPLOAD_DIR resolved and absolute
app.config[ 'UPLOAD_DIR' ] = abspath( expandvars( expanduser( app.config[ 'UPLOAD_DIR' ] ) ) )
safe_makedirs( app.config[ 'UPLOAD_DIR' ] )

# compute a digest of TAR_DATA to show at root URL
app.config[ 'TAR_DIGEST' ] = mac( app.config[ 'SECRET_KEY' ], app.config[ 'TAR_DATA' ], sha256 ).hexdigest()

# setup logging
if not app.debug:
	sh = StreamHandler()
	sh.setLevel( INFO )
	f = Formatter( '%(asctime)s [%(process)s] [%(levelname)s] Flask: %(name)s [in %(pathname)s:%(lineno)d] %(message)s', '%Y-%m-%d %H:%M:%S' )
	sh.setFormatter( f )
	app.logger.addHandler( sh )
	app.logger.setLevel( INFO )
EVENTS_LOG = getLogger( 'EVENTS_LOG' )
EVENTS_LOG.setLevel( INFO )
fh = FileHandler( join( app.config[ 'UPLOAD_DIR' ], 'EVENTS-{}.log'.format( getpid() ) ) )
fh.setLevel( INFO )
f = Formatter( '%(asctime)s: %(message)s', '%Y-%m-%d %H:%M:%S' )
fh.setFormatter( f )
Exemplo n.º 5
0
def _sign(uid):
    return '{0}:{1}'.format(
        uid,
        mac(app.config['SECRET_KEY'], uid, sha256).hexdigest())
Exemplo n.º 6
0
    exit('Error loading TM_SETTINGS, is such variable defined?')

# setup the loader so that if finds the templates also in the zip file
app.jinja_loader = PackageLoader('tm', 'client')

# setup the endpoint
if not 'BASE_URL' in app.config:
    app.config['BASE_URL'] = None

# make UPLOAD_DIR resolved and absolute
app.config['UPLOAD_DIR'] = abspath(
    expandvars(expanduser(app.config['UPLOAD_DIR'])))
safe_makedirs(app.config['UPLOAD_DIR'])

# compute a digest of TAR_DATA to show at root URL
app.config['TAR_DIGEST'] = mac(app.config['SECRET_KEY'],
                               app.config['TAR_DATA'], sha256).hexdigest()

# setup logging
if not app.debug:
    sh = StreamHandler()
    sh.setLevel(INFO)
    f = Formatter(
        '%(asctime)s [%(process)s] [%(levelname)s] Flask: %(name)s [in %(pathname)s:%(lineno)d] %(message)s',
        '%Y-%m-%d %H:%M:%S')
    sh.setFormatter(f)
    app.logger.addHandler(sh)
    app.logger.setLevel(INFO)
EVENTS_LOG = getLogger('EVENTS_LOG')
EVENTS_LOG.setLevel(INFO)
fh = FileHandler(
    join(app.config['UPLOAD_DIR'], 'EVENTS-{}.log'.format(getpid())))
Exemplo n.º 7
0
def _sign( uid ):
	return '{0}:{1}'.format( uid, mac( ARBITER_SECRET, uid, sha256 ).hexdigest() )