Ejemplo n.º 1
0
def run_ocsync(local_folder, remote_folder="", n=None, user_num=None):
    """ Run the ocsync for local_folder against remote_folder (or the main folder on the owncloud account if remote_folder is None).
    Repeat the sync n times. If n given then n -> config.oc_sync_repeat (default 1).
    """
    global ocsync_cnt
    from smashbox.utilities import reflection

    if n is None:
        n = config.oc_sync_repeat

    current_step = reflection.getCurrentStep()

    ocsync_cnt.setdefault(current_step, 0)

    local_folder += '/'  # FIXME: HACK - is a trailing slash really needed by 1.6 owncloudcmd client?

    for i in range(n):
        t0 = datetime.datetime.now()
        cmd = config.oc_sync_cmd + ' ' + local_folder + ' ' + oc_webdav_url(
            'owncloud', remote_folder, user_num
        ) + " >> " + config.rundir + "/%s-ocsync.step%02d.cnt%03d.log 2>&1" % (
            reflection.getProcessName(), current_step,
            ocsync_cnt[current_step])
        runcmd(cmd, ignore_exitcode=True)  # exitcode of ocsync is not reliable
        logger.info('sync cmd is: %s', cmd)
        logger.info('sync finished: %s', datetime.datetime.now() - t0)
        ocsync_cnt[current_step] += 1
Ejemplo n.º 2
0
def run_ocsync(local_folder, remote_folder="", n=None, user_num=None):
    """ Run the ocsync for local_folder against remote_folder (or the main folder on the owncloud account if remote_folder is None).
    Repeat the sync n times. If n given then n -> config.oc_sync_repeat (default 1).
    """
    global ocsync_cnt
    from smashbox.utilities import reflection

    if n is None:
        n = config.oc_sync_repeat

    current_step = reflection.getCurrentStep()

    ocsync_cnt.setdefault(current_step,0)

    if platform.system() != "Windows":
        local_folder += os.sep # FIXME: HACK - is a trailing slash really needed by 1.6 owncloudcmd client?

    for i in range(n):
        t0 = datetime.datetime.now()
        cmd = config.oc_sync_cmd+[local_folder,oc_webdav_url('owncloud',remote_folder,user_num)]
        logf = file(os.path.join(config.rundir,"%s-ocsync.step%02d.cnt%03d.log"%(reflection.getProcessName(),current_step,ocsync_cnt[current_step])),"wb")

        logger.info('sync cmd is: %s',repr(cmd))

        process = subprocess.Popen(cmd, shell=False, stdout=logf, stderr=subprocess.STDOUT)
        process.communicate()

        if process.returncode != 0:
            msg = "Non-zero exit code %d from command %s" % (process.returncode, repr(cmd))
            logger.warning(msg)

        logger.info('sync finished: %s',datetime.datetime.now()-t0)
        ocsync_cnt[current_step]+=1
Ejemplo n.º 3
0
def make_workdir(name=None):
    """ Create a worker directory in the current run directory for the test (by default the name is derived from the worker's name). 
    """
    from smashbox.utilities import reflection
    if name is None:
        name = reflection.getProcessName()
    d = os.path.join(config.rundir,name)
    mkdir(d)
    logger.info('make_workdir %s',d)
    return d
Ejemplo n.º 4
0
def make_workdir(name=None):
    """ Create a worker directory in the current run directory for the test (by default the name is derived from the worker's name). 
    """
    from smashbox.utilities import reflection
    if name is None:
        name = reflection.getProcessName()
    d = os.path.join(config.rundir, name)
    mkdir(d)
    logger.info('make_workdir %s', d)
    return d
Ejemplo n.º 5
0
 def checker(*args, **kwargs): 
     import importlib
     #check if there was specified any additional engine using e.g. --option engine=dropbox
     try:
         engine = getattr(config, "engine")
         imported_mod = importlib.import_module('smashbox.test_manager.non_native_engine')
         imported_sync_class = getattr(imported_mod, config.engine)
         imported_class_function = getattr(imported_sync_class, func.__name__)
         from smashbox.utilities import reflection
         worker_name = reflection.getProcessName()
         return imported_class_function(args,config,worker_name) #print "executing sync engine custom function %s"%func.__name__
     except Exception, e:
         return func(*args, **kwargs) #
Ejemplo n.º 6
0
def run_ocsync(local_folder, remote_folder="", n=None, user_num=None):
    """ Run the ocsync for local_folder against remote_folder (or the main folder on the owncloud account if remote_folder is None).
    Repeat the sync n times. If n given then n -> config.oc_sync_repeat (default 1).
    """
    global ocsync_cnt
    from smashbox.utilities import reflection

    if n is None:
        n = config.oc_sync_repeat

    current_step = reflection.getCurrentStep()

    ocsync_cnt.setdefault(current_step,0)

    local_folder += '/' # FIXME: HACK - is a trailing slash really needed by 1.6 owncloudcmd client?

    for i in range(n):
        t0 = datetime.datetime.now()
        cmd = config.oc_sync_cmd+' '+local_folder+' '+oc_webdav_url('owncloud',remote_folder,user_num) + " >> "+config.rundir+"/%s-ocsync.step%02d.cnt%03d.log 2>&1"%(reflection.getProcessName(),current_step,ocsync_cnt[current_step])
        runcmd(cmd, ignore_exitcode=True)  # exitcode of ocsync is not reliable
        logger.info('sync cmd is: %s',cmd)
        logger.info('sync finished: %s',datetime.datetime.now()-t0)
        ocsync_cnt[current_step]+=1
Ejemplo n.º 7
0
def run_ocsync(local_folder,remote_folder="",N=None):
    """ Run the ocsync for local_folder against remote_folder (or the main folder on the owncloud account if remote_folder is None).
    Repeat the sync N times. If N not given then N -> config.oc_sync_repeat (default 1).
    """
    global ocsync_cnt
    from smashbox.utilities import reflection
    if N is None:
        N = config.oc_sync_repeat

    for i in range(N):
        t0 = datetime.datetime.now()
        cmd = config.oc_sync_cmd+' '+local_folder+' '+oc_webdav_url('owncloud',remote_folder)+" >> "+ config.rundir+"/%s-ocsync.step%02d.cnt%03d.log 2>&1"%(reflection.getProcessName(),reflection.getCurrentStep(),ocsync_cnt)
        runcmd(cmd,ignore_exitcode=True) # exitcode of ocsync is not reliable
        logger.info('sync finished: %s',datetime.datetime.now()-t0)
        ocsync_cnt+=1
Ejemplo n.º 8
0
def run_ocsync(local_folder, remote_folder="", n=None, user_num=None, option = None):
    """ Run the ocsync for local_folder against remote_folder (or the main folder on the owncloud account if remote_folder is None).
    Repeat the sync n times. If n given then n -> config.oc_sync_repeat (default 1).
    Option parameters is used in case of non-native engine and could specify specific behaviour of sync in the specific step. 
    """
    
    global ocsync_cnt,sync_exec_time_array
    from smashbox.utilities import reflection

    if n is None:
        n = config.oc_sync_repeat

    current_step = reflection.getCurrentStep()
    
    ocsync_cnt.setdefault(current_step,0)

    local_folder += '/' # FIXME: HACK - is a trailing slash really needed by 1.6 owncloudcmd client?

    for i in range(n):
        cmd = config.oc_sync_cmd+' '+local_folder+' '+oc_webdav_url('owncloud',remote_folder,user_num) + " >> "+config.rundir+"/%s-ocsync.step%02d.cnt%03d.log 2>&1"%(reflection.getProcessName(),current_step,ocsync_cnt[current_step])
        sync_exec_time = sync_engine(cmd,option)
        sync_exec_time_array.append(sync_exec_time)  
        logger.info('sync finished: %s s'%sync_exec_time)
        ocsync_cnt[current_step]+=1