<s> from datetime import timedelta <EOL> import catcher <EOL> import locale <EOL> import logging <EOL> import subprocess <EOL> import sys <EOL> import time <EOL> import traceback <EOL> import ajenti <EOL> def public ( f ) : <EOL> """<STR_LIT>""" <EOL> all = sys . modules [ f . __module__ ] . __dict__ . setdefault ( '<STR_LIT>' , [ ] ) <EOL> if f . __name__ not in all : <EOL> all . append ( f . __name__ ) <EOL> return f <EOL> public ( public ) <EOL> @ public <EOL> def str_fsize ( sz ) : <EOL> """<STR_LIT>""" <EOL> if sz < <NUM_LIT> : <EOL> return '<STR_LIT>' % sz <EOL> sz /= <NUM_LIT> <EOL> if sz < <NUM_LIT> : <EOL> return '<STR_LIT>' % sz <EOL> sz /= <NUM_LIT> <EOL> if sz < <NUM_LIT> : <EOL> return '<STR_LIT>' % sz <EOL> sz /= <NUM_LIT> <EOL> if sz < <NUM_LIT> : <EOL> return '<STR_LIT>' % sz <EOL> sz /= <NUM_LIT> <EOL> return '<STR_LIT>' % sz <EOL> @ public <EOL> def str_timedelta ( s ) : <EOL> """<STR_LIT>""" <EOL> return str ( timedelta ( <NUM_LIT:0> , s ) ) . split ( '<STR_LIT:.>' ) [ <NUM_LIT:0> ] <EOL> @ public <EOL> def cache_value ( duration = None ) : <EOL> """<STR_LIT>""" <EOL> def decorator ( fx ) : <EOL> fx . __cached = None <EOL> fx . __cached_at = <NUM_LIT:0> <EOL> def wrapper ( * args , ** kwargs ) : <EOL> dt = time . time ( ) - fx . __cached_at <EOL> if ( dt > duration and duration is not None ) or ( fx . __cached_at == <NUM_LIT:0> and duration is None ) : <EOL> val = fx ( * args , ** kwargs ) <EOL> fx . __cached = val <EOL> fx . __cached_at = time . time ( ) <EOL> else : <EOL> val = fx . __cached <EOL> return val <EOL> wrapper . __doc__ = fx . __doc__ <EOL> return wrapper <EOL> return decorator <EOL> @ public <EOL> def platform_select ( ** values ) : <EOL> """<STR_LIT>""" <EOL> if ajenti . platform_unmapped in values : <EOL> return values [ ajenti . platform_unmapped ] <EOL> if ajenti . platform in values : <EOL> return values [ ajenti . platform ] <EOL> return values . get ( '<STR_LIT:default>' , None ) <EOL> @ public <EOL> def make_report ( e ) : <EOL> """<STR_LIT>""" <EOL> import platform as _platform <EOL> from ajenti . plugins import manager <EOL> from ajenti import platform , platform_unmapped , platform_string , installation_uid , version , debug <EOL> logging . blackbox . stop ( ) <EOL> tb = traceback . format_exc ( e ) <EOL> tb = '<STR_LIT:\n>' . join ( '<STR_LIT:U+0020>' + x for x in tb . splitlines ( ) ) <EOL> log = logging . blackbox . buffer <EOL> log = '<STR_LIT:\n>' . join ( '<STR_LIT:U+0020>' + x for x in log . splitlines ( ) ) <EOL> catcher_url = None <EOL> try : <EOL> report = catcher . collect ( e ) <EOL> html = catcher . formatters . HTMLFormatter ( ) . format ( report , maxdepth = <NUM_LIT:3> ) <EOL> catcher_url = catcher . uploaders . AjentiOrgUploader ( ) . upload ( html ) <EOL> except : <EOL> pass <EOL> import gevent <EOL> import greenlet <EOL> import reconfigure <EOL> import requests <EOL> import psutil <EOL> return """<STR_LIT>""" % ( <EOL> version , <EOL> platform , platform_unmapped , platform_string . strip ( ) , <EOL> subprocess . check_output ( [ '<STR_LIT>' , '<STR_LIT>' ] ) . strip ( ) , <EOL> '<STR_LIT:.>' . join ( [ str ( x ) for x in _platform . python_version_tuple ( ) ] ) , <EOL> installation_uid , <EOL> debug , <EOL> catcher_url or '<STR_LIT>' , <EOL> '<STR_LIT:U+002CU+0020>' . join ( sorted ( manager . get_order ( ) ) ) , <EOL> gevent . __version__ , <EOL> greenlet . __version__ , <EOL> reconfigure . __version__ , <EOL> requests . __version__ , <EOL> psutil . __version__ , <EOL> tb , <EOL> log , <EOL> ) </s>
