Beispiel #1
0
 def create(self, ex, tu):
     print self.__class__.__name__ + ' ' + sys._getframe(
     ).f_code.co_name + ' ' + 'start'
     exec_time = datetime.now() + timedelta(seconds=3)
     scheduler.add_job(call,
                       'date',
                       run_date=exec_time,
                       args=[MODULE, CALL[2][0], (1, ), CALL[2][1], (1, 2)])
     print self.__class__.__name__ + ' ' + sys._getframe(
     ).f_code.co_name + ' ' + 'end'
Beispiel #2
0
 def wait_dm(self, cs, dm):
     print self.__class__.__name__ + ' ' + sys._getframe(
     ).f_code.co_name + ' ' + 'start'
     exec_time = datetime.now() + timedelta(seconds=3)
     scheduler.add_job(
         call,
         'date',
         run_date=exec_time,
         args=[MODULE, CALL[5][0], (1, 2, 3), CALL[5][1], (1, 2, 3, 3)])
     print self.__class__.__name__ + ' ' + sys._getframe(
     ).f_code.co_name + ' ' + 'end'
Beispiel #3
0
 def wait_vm(self, cs, dm, vm, next=None):
     print self.__class__.__name__ + ' ' + sys._getframe(
     ).f_code.co_name + ' ' + 'start'
     exec_time = datetime.now() + timedelta(seconds=3)
     if next is not None:
         scheduler.add_job(
             call,
             'date',
             run_date=exec_time,
             args=[MODULE, CALL[next][0], (1, 2, 3), CALL[next][1], (1, 5)])
     print self.__class__.__name__ + ' ' + sys._getframe(
     ).f_code.co_name + ' ' + 'end'
Beispiel #4
0
 def wait_async(self, id, next):
     print self.__class__.__name__ + ' ' + sys._getframe(
     ).f_code.co_name + ' ' + 'start'
     exec_time = datetime.now() + timedelta(seconds=3)
     if next == 1:
         scheduler.add_job(
             call,
             'date',
             run_date=exec_time,
             args=[MODULE, CALL[next][0], (1, ), CALL[next][1], (1, 2)])
     elif next == 4:
         scheduler.add_job(
             call,
             'date',
             run_date=exec_time,
             args=[MODULE, CALL[next][0], (1, 2, 3), CALL[next][1], (1, 2)])
     else:
         scheduler.add_job(call,
                           'date',
                           run_date=exec_time,
                           args=[
                               MODULE, CALL[next][0], (1, 2, 3),
                               CALL[next][1], (1, 2, 3)
                           ])
     print self.__class__.__name__ + ' ' + sys._getframe(
     ).f_code.co_name + ' ' + 'end'
__author__ = 'Yifu Huang'

from src.azureformation.scheduler import (
    scheduler, )
from datetime import (
    datetime,
    timedelta,
)
import time
import importlib


def alarm(mdl, cls, func):
    mdl = importlib.import_module(mdl)
    cls = getattr(mdl, cls)
    func = getattr(cls('a', 'b', 'c'), func)
    func()


alarm_time = datetime.now() + timedelta(seconds=10)
scheduler.add_job(alarm,
                  'date',
                  run_date=alarm_time,
                  args=['test.testClass', 'Pao', 'funcA'])
while True:
    print 'main'
    time.sleep(10)
Beispiel #6
0
def run_job(mdl_cls_func, cls_args, func_args, second=DEFAULT_TICK):
    exec_time = datetime.now() + timedelta(seconds=second)
    scheduler.add_job(call,
                      'date',
                      run_date=exec_time,
                      args=[mdl_cls_func, cls_args, func_args])
Beispiel #7
0
class VirtualMachine():
    def __init__(self, service):
        pass

    def create(self, ex, tu):
        print self.__class__.__name__ + ' ' + sys._getframe(
        ).f_code.co_name + ' ' + 'start'
        exec_time = datetime.now() + timedelta(seconds=3)
        scheduler.add_job(
            call,
            'date',
            run_date=exec_time,
            args=[MODULE, CALL[3][0], (1, 2, 3), CALL[3][1], (1, 4)])
        print self.__class__.__name__ + ' ' + sys._getframe(
        ).f_code.co_name + ' ' + 'end'


if __name__ == '__main__':
    # create storage account first
    service = Service(1, 2, 3)
    exec_time = datetime.now() + timedelta(seconds=3)
    scheduler.add_job(
        call,
        'date',
        run_date=exec_time,
        args=[MODULE, CALL[0][0], (service, ), CALL[0][1], (1, 2)])
    # keep main thread alive
    while True:
        print 'main'
        time.sleep(10)