<s> import json <EOL> import datetime <EOL> from peewee import Proxy , TextField , FloatField , CharField , IntegerField , SqliteDatabase , Model , DateTimeField <EOL> db = Proxy ( ) <EOL> class Result ( Model ) : <EOL> """<STR_LIT>""" <EOL> error = TextField ( null = True ) <EOL> scriptrun_time = FloatField ( ) <EOL> elapsed = FloatField ( ) <EOL> epoch = FloatField ( ) <EOL> custom_timers = TextField ( null = True ) <EOL> turret_name = CharField ( default = '<STR_LIT>' ) <EOL> def to_dict ( self ) : <EOL> return { <EOL> '<STR_LIT:error>' : self . error , <EOL> '<STR_LIT>' : self . scriptrun_time , <EOL> '<STR_LIT>' : self . elapsed , <EOL> '<STR_LIT>' : self . epoch , <EOL> '<STR_LIT>' : json . loads ( self . custom_timers ) , <EOL> '<STR_LIT>' : self . turret_name <EOL> } <EOL> class Meta : <EOL> database = db <EOL> class Turret ( Model ) : <EOL> """<STR_LIT>""" <EOL> name = TextField ( ) <EOL> uuid = TextField ( ) <EOL> cannons = IntegerField ( ) <EOL> script = TextField ( ) <EOL> rampup = IntegerField ( ) <EOL> status = TextField ( ) <EOL> updated_at = DateTimeField ( default = datetime . datetime . now ( ) ) <EOL> def save ( self , * args , ** kwargs ) : <EOL> self . updated_at = datetime . datetime . now ( ) <EOL> return super ( Turret , self ) . save ( * args , ** kwargs ) <EOL> def to_dict ( self ) : <EOL> return { <EOL> '<STR_LIT:name>' : self . name , <EOL> '<STR_LIT>' : self . uuid , <EOL> '<STR_LIT>' : self . cannons , <EOL> '<STR_LIT>' : self . script , <EOL> '<STR_LIT>' : self . rampup , <EOL> '<STR_LIT:status>' : self . status , <EOL> '<STR_LIT>' : self . updated_at <EOL> } <EOL> class Meta : <EOL> database = db <EOL> def set_database ( db_path , proxy , config ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' in config and config [ '<STR_LIT>' ] is True : <EOL> database = SqliteDatabase ( '<STR_LIT>' , check_same_thread = False ) <EOL> else : <EOL> database = SqliteDatabase ( db_path , check_same_thread = False ) <EOL> proxy . initialize ( database ) </s>
