<s> import re <EOL> import datetime <EOL> import rrdtool <EOL> import karesansui <EOL> from karesansui . lib . const import GRAPH_COMMON_PARAM , DEFAULT_LANGS <EOL> from karesansui . lib . utils import is_readable , generate_phrase <EOL> def is_df_file_exist ( rrd_dir , dev ) : <EOL> ret = True <EOL> rrd_filepath = ( "<STR_LIT>" % ( rrd_dir , dev ) , <EOL> ) <EOL> for filepath in rrd_filepath : <EOL> if is_readable ( filepath ) is False : <EOL> ret = False <EOL> return ret <EOL> def create_df_graph ( _ , lang , graph_dir , rrd_dir , start , end , dev , type = None ) : <EOL> graph_filename = "<STR_LIT>" % ( generate_phrase ( <NUM_LIT:12> , '<STR_LIT>' ) ) <EOL> graph_filepath = "<STR_LIT>" % ( graph_dir , graph_filename ) <EOL> rrd_filepath = ( "<STR_LIT>" % ( rrd_dir , dev ) , <EOL> ) <EOL> for filepath in rrd_filepath : <EOL> if is_readable ( filepath ) is False : <EOL> return "<STR_LIT>" <EOL> legend_header_label = { "<STR_LIT>" : _ ( '<STR_LIT>' ) , <EOL> "<STR_LIT>" : _ ( '<STR_LIT>' ) , <EOL> "<STR_LIT>" : _ ( '<STR_LIT>' ) , <EOL> "<STR_LIT>" : _ ( '<STR_LIT>' ) , <EOL> } <EOL> for key in legend_header_label . keys ( ) : <EOL> if re . search ( u"<STR_LIT>" , legend_header_label [ key ] ) : <EOL> legend_header_label [ key ] = "<STR_LIT>" % ( legend_header_label [ key ] . encode ( "<STR_LIT:utf-8>" ) ) <EOL> else : <EOL> legend_header_label [ key ] = "<STR_LIT:%s>" % ( legend_header_label [ key ] . encode ( "<STR_LIT:utf-8>" ) ) <EOL> legend_header = "<STR_LIT>" % ( legend_header_label [ '<STR_LIT>' ] , <EOL> legend_header_label [ '<STR_LIT>' ] , <EOL> legend_header_label [ '<STR_LIT>' ] , <EOL> legend_header_label [ '<STR_LIT>' ] <EOL> ) <EOL> title = "<STR_LIT>" % ( dev ) <EOL> legend = { "<STR_LIT>" : _ ( '<STR_LIT>' ) , <EOL> "<STR_LIT>" : _ ( '<STR_LIT>' ) , <EOL> } <EOL> reg = re . compile ( u"<STR_LIT>" ) <EOL> for key in legend . keys ( ) : <EOL> if key == "<STR_LIT>" : <EOL> if reg . search ( legend [ key ] ) : <EOL> legend [ key ] = "<STR_LIT>" % ( legend [ key ] . encode ( "<STR_LIT:utf-8>" ) ) <EOL> else : <EOL> legend [ key ] = "<STR_LIT:%s>" % ( legend [ key ] . encode ( "<STR_LIT:utf-8>" ) ) <EOL> elif key == "<STR_LIT>" : <EOL> if reg . search ( legend [ key ] ) : <EOL> legend [ key ] = "<STR_LIT>" % ( legend [ key ] . encode ( "<STR_LIT:utf-8>" ) ) <EOL> else : <EOL> legend [ key ] = "<STR_LIT:%s>" % ( legend [ key ] . encode ( "<STR_LIT:utf-8>" ) ) <EOL> else : <EOL> legend [ key ] = "<STR_LIT:%s>" % ( legend [ key ] . encode ( "<STR_LIT:utf-8>" ) ) <EOL> created_label = _ ( '<STR_LIT>' ) <EOL> if re . search ( u"<STR_LIT>" , created_label ) : <EOL> created_label = "<STR_LIT>" % ( created_label . encode ( "<STR_LIT:utf-8>" ) ) <EOL> else : <EOL> created_label = "<STR_LIT:%s>" % ( created_label . encode ( "<STR_LIT:utf-8>" ) ) <EOL> created_time = "<STR_LIT:%s>" % ( datetime . datetime . today ( ) . strftime ( DEFAULT_LANGS [ lang ] [ '<STR_LIT>' ] [ <NUM_LIT:1> ] ) ) <EOL> created_time = re . sub ( r'<STR_LIT::>' , '<STR_LIT>' , created_time ) <EOL> legend_footer = "<STR_LIT>" % ( created_label , created_time ) <EOL> data = rrdtool . graph ( graph_filepath , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , title , <EOL> "<STR_LIT>" , _ ( '<STR_LIT>' ) . encode ( "<STR_LIT:utf-8>" ) , <EOL> "<STR_LIT>" , "<STR_LIT:0>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , start , <EOL> "<STR_LIT>" , end , <EOL> "<STR_LIT>" % ( rrd_filepath [ <NUM_LIT:0> ] ) , <EOL> "<STR_LIT>" % ( rrd_filepath [ <NUM_LIT:0> ] ) , <EOL> "<STR_LIT>" % legend_footer , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" % ( legend [ '<STR_LIT>' ] ) , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" % ( legend [ '<STR_LIT>' ] ) , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" % ( legend_header ) , <EOL> "<STR_LIT>" , <EOL> ) <EOL> return graph_filepath </s>
