Beispiel #1
0
 def __init__(self, worker_num, ipaddr, tests, phone_cfg, user_cfg,
              autophone_queue, cmd_queue, logfile_prefix, loglevel, mailer,
              build_cache_port):
     self.worker_num = worker_num
     self.ipaddr = ipaddr
     self.tests = tests
     self.phone_cfg = phone_cfg
     self.user_cfg = user_cfg
     self.autophone_queue = autophone_queue
     self.cmd_queue = cmd_queue
     self.logfile = logfile_prefix + '.log'
     self.outfile = logfile_prefix + '.out'
     self.loglevel = loglevel
     self.mailer = mailer
     self.build_cache_port = build_cache_port
     self._stop = False
     self.p = None
     self.jobs = jobs.Jobs(self.mailer, self.phone_cfg['phoneid'])
     self.current_build = None
     self.last_ping = None
     self._dm = None
     self.status = None
     self.logger = logging.getLogger('autophone.worker.subprocess')
     self.loggerdeco = LogDecorator(self.logger, {
         'phoneid': self.phone_cfg['phoneid'],
         'phoneip': self.phone_cfg['ip']
     }, '%(phoneid)s|%(phoneip)s|%(message)s')
Beispiel #2
0
 def __init__(self):
     self.jobs = JOBS.Jobs()
     self.current_day = None
     # TODO: Necessary?
     #  self.opening_menu = MENU.OpeningMenu()
     #Character('random') creates charecter on start menu becasue
     #its an error.
     self.character = None
     self.locations = LOCATIONS.Locations()
     self.events = EVENTS.Events()
     self.notices = Notices()
Beispiel #3
0
    def __init__(self, handlers):
                
        settings = {
            'template_path': os.path.abspath(os.path.join(os.path.dirname(__main__.__file__), "templates")),
            'static_path': os.path.abspath(os.path.join(os.path.dirname(__main__.__file__), "static"))
        }
        
        if 'tornado' in config:
            tornado_settings = config['tornado']
            for key in tornado_settings.keys():
                settings[key] = tornado_settings[key]        

        tornado.web.Application.__init__(self, handlers, **settings)
        
        if 'mysql' in config:
            log.info("--> tornado initializing mysql")
            import database
            try:
                self.db = database.Connection()
            except Exception as e:
                log.error("Could not connect to MySQL: %s" % log.exc(e))   
        elif 'mongo' in config:    
            log.info("--> tornado initializing mongo")
            try:
                mongo = config['mongo']
                import pymongo                
                connection = pymongo.Connection(mongo['host'])
                self.db = connection[mongo['database']]
            except Exception as e:
                log.error("Could not connect to mongo: %s" % log.exc(e))
        if 'redis' in config:
            log.info("--> tornado initializing redis")
            import redis
            self.redis = redis.StrictRedis()
        if 'memcache' in config:
            log.info("--> torando initializing memcache")
            import memcache
            self.cache = memcache.Client([config['memcache']['address'] + ":" + str(config['memcache']['port'])])
            
        self.jobs = None    
        if 'beanstalk' in config:    
            log.info("--> tornado initializing beanstalk")
            import jobs
            self.jobs = jobs.Jobs()  
            
        # intialize oauth server
        try:
            self.oauth_server = oauth2.Server(signature_methods={'HMAC-SHA1': oauth2.SignatureMethod_HMAC_SHA1()})                                                    
        except ImportError:
            self.oauth_server = None
            
        Application.instance = self          
Beispiel #4
0
    def __init__(self, handlers):

        settings = {
            'template_path':
            os.path.abspath(
                os.path.join(os.path.dirname(__main__.__file__), "templates")),
            'static_path':
            os.path.abspath(
                os.path.join(os.path.dirname(__main__.__file__), "static")),
            'cookie_secret':
            base64.b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes),
            'xsrf_cookies':
            False
        }

        if 'mongo' in config:
            log.info("Initializing mongo")
            try:
                mongo = config['mongo']
                from pymongo import MongoClient
                client = MongoClient(mongo['host'], mongo['port'])
                self.db = client[mongo['database']]
                log.info("--> %s" % self.db)
            except Exception as e:
                log.error("Could not connect to mongo: %s" % log.exc(e))
        if 'server' in config:
            tornado_settings = config['server']
            for key in list(tornado_settings.keys()):
                settings[key] = tornado_settings[key]

        tornado.web.Application.__init__(self, handlers, **settings)

        # # not ported or tested with Python 3
        # if 'memcache' in config:
        #     log.info("--> torando initializing memcache")
        #     import memcache
        #     self.cache = memcache.Client([config['memcache']['address'] + ":" + str(config['memcache']['port'])])

        self.jobs = None
        if 'beanstalk' in config:
            log.info("--> tornado initializing beanstalk")
            import jobs
            self.jobs = jobs.Jobs()

        Application.instance = self
Beispiel #5
0
    def __init__(self,
                 apps_list='apps.csv',
                 configs_list='configs.csv',
                 log_dir="log/",
                 slot_count=16,
                 batch_count=100,
                 video_mode=False,
                 num_of_operations=1000,
                 reuse_emulator=True):
        self.apps_list = apps_list
        self.configs_list = configs_list
        self.slot_count = slot_count
        self.batch_count = batch_count
        self.video_mode = video_mode
        self.num_of_operations = num_of_operations
        self.reuse_emulator = reuse_emulator
        self.log_dir = log_dir
        self.load()
        self.jobs = jobs.Jobs(slot_count)

        signal.signal(signal.SIGUSR1, self.handle_reload_sig)
Beispiel #6
0
    parser.add_argument(
        '--database',
        choices=['hbase', 'hbasehadoop', 'redis'],
        default='hbasehadoop',
        help=
        'Select which database to use as our backend.  Those ending in hadoop use it for job processing.'
    )
    ARGS = parser.parse_args()
    if ARGS.raven:
        import raven
        RAVEN = raven.Client(ARGS.raven)
    THRIFT_POOL = gevent.queue.Queue()

    USERS = Users(ARGS.redis_host, ARGS.redis_port, 0)
    YUBIKEY = Yubikey(ARGS.redis_host, ARGS.redis_port, 1)
    JOBS = jobs.Jobs(ARGS.redis_host, ARGS.redis_port, 3,
                     ARGS.annotations_redis_host, ARGS.annotations_redis_port)
    # Set necessary globals in tables module
    tables.VERSION = VERSION = 'v0'
    tables.thrift_lock = thrift_lock
    tables.thrift_new = thrift_new
    tables.JOBS = JOBS


def print_request():
    ks = [
        'auth', 'content_length', 'content_type', 'environ', 'fullpath',
        'is_ajax', 'is_xhr', 'method', 'path', 'query_string', 'remote_addr',
        'remote_route', 'script_name', 'url', 'urlparts'
    ]
    for k in ks:
        print('%s: %s' % (k, str(getattr(bottle.request, k))))
Beispiel #7
0
import jobs

# Instantiating some jobs
fake_street = jobs.Jobs("123 Fake St Phoenix, AZ", "2-1-15")
fake_street2 = jobs.Jobs("5496 E 1st St Tucson, AZ", "2-4-15")
fake_street3 = jobs.Jobs("9999 S Lake Dr, Phoenix, AZ", "2-17-15")
fake_street4 = jobs.Jobs("1983 'Mermaid I should be' St", "3-16-15")

# Adding some phases to the jobs for testing
# Job 1
fake_street.add_phase('Paint', 'Arturo')
fake_street.add_phase('Cleaning', 'Addrienne')
fake_street.add_phase('Flooring', 'Star flooring')
# Job 2
fake_street2.add_phase('Paint', 'Ramsey Painting')
fake_street2.add_phase('Cleaning', 'La Maids')
fake_street2.add_phase('Repairs', 'Arts Handyworks')
# Job 3
fake_street3.add_phase('Repairs', 'Magna Building')
fake_street3.add_phase('Landscape', 'Jason')
fake_street3.add_phase('Electrical', 'Ruoff Electric')
fake_street3.add_phase('Supervisor', 'Kevin')
# Job 4
fake_street4.add_phase('HVAC', 'Custom Air')
fake_street4.add_phase('Repairs', 'Arts Hand Works')
fake_street4.add_phase('Shower Enclosure', 'Diamond Glass')
fake_street4.add_phase('Shower / Backsplash Tile', 'Master Stonework')


# Testing method for printing jobs, due date and phases
def showOpenJobs():