<s> from django . db import models <EOL> import random <EOL> def _random_slug ( ) : <EOL> alphabet = '<STR_LIT>' <EOL> result = '<STR_LIT>' <EOL> for i in range ( <NUM_LIT:16> ) : <EOL> result += random . choice ( alphabet ) <EOL> return result <EOL> class Sandbox ( models . Model ) : <EOL> CREATED = '<STR_LIT>' <EOL> RUNNING = '<STR_LIT>' <EOL> TERMINATED = '<STR_LIT>' <EOL> STATUSES = ( ( CREATED , '<STR_LIT>' ) , <EOL> ( RUNNING , '<STR_LIT>' ) , <EOL> ( TERMINATED , '<STR_LIT>' ) ) <EOL> slug = models . SlugField ( max_length = <NUM_LIT:32> , default = _random_slug ) <EOL> owner_app = models . ForeignKey ( '<STR_LIT>' ) <EOL> time = models . DateTimeField ( auto_now = True ) <EOL> image = models . ForeignKey ( '<STR_LIT>' ) <EOL> docker_server = models . ForeignKey ( '<STR_LIT>' , null = True ) <EOL> container_id = models . SlugField ( max_length = <NUM_LIT> , null = True ) <EOL> cmd = models . TextField ( ) <EOL> status = models . CharField ( choices = STATUSES , max_length = <NUM_LIT:16> , default = CREATED ) <EOL> def __unicode__ ( self ) : <EOL> return self . slug <EOL> def to_dict ( self ) : <EOL> d = { } <EOL> d [ '<STR_LIT:image>' ] = self . image . slug <EOL> d [ '<STR_LIT>' ] = self . cmd <EOL> d [ '<STR_LIT:status>' ] = self . status <EOL> try : <EOL> d [ '<STR_LIT>' ] = self . log . return_code <EOL> d [ '<STR_LIT>' ] = self . log . logs <EOL> except : <EOL> d [ '<STR_LIT>' ] = None <EOL> d [ '<STR_LIT>' ] = None <EOL> return d <EOL> class SandboxLog ( models . Model ) : <EOL> sandbox = models . OneToOneField ( '<STR_LIT>' , related_name = "<STR_LIT>" ) <EOL> return_code = models . IntegerField ( null = True , blank = True ) <EOL> logs = models . TextField ( ) <EOL> def __unicode__ ( self ) : <EOL> return self . sandbox . slug </s>
