# Path: afl_utils/afl_cron.py
# class AflCronDaemon(object):
#     def __init__(self, config_file, quiet=False):
#     def load_config(self, config_file):
#     def get_module(self, module_path):
#     def get_member(self, module, member_name):
#     def run_job(self, job):
#     def run(self):
# def show_info():
# def main(argv):
# 
# Path: afl_utils/afl_sync.py
# class AflBaseSync(object):
# class AflRsync(AflBaseSync):
#     def __init__(self, server_config, fuzzer_config):
#     def __init__(self, server_config, fuzzer_config):
#     def __prepare_rsync_commandline(self, local_path, remote_path, rsync_options=list(_rsync_default_options),
#                                     rsync_excludes=list([]), rsync_get=False):
#     def __invoke_rsync(self, rsync_cmdline):
#     def __get_fuzzers(self):
#     def rsync_put(self, local_path, remote_path, rsync_options=list(_rsync_default_options), rsync_excludes=list([])):
#     def rsync_get(self, remote_path, local_path, rsync_options=list(_rsync_default_options), rsync_excludes=list([])):
#     def push(self):
#     def pull(self):
#     def sync(self):
# def show_info():
# def main(argv):
# 
# Path: afl_utils/afl_cron.py
# class AflCronDaemon(object):
#     def __init__(self, config_file, quiet=False):
#         self.config = self.load_config(config_file)
#         self.quiet = quiet
# 
#     def load_config(self, config_file):
#         with open(config_file, 'r') as raw_config:
#             config = json.load(raw_config)
#         return config
# 
#     def get_module(self, module_path):
#         module_name = module_path.rsplit('.', 1)[1]
#         try:
#             module = __import__(module_path, fromlist=[module_name])
#         except ImportError:
#             raise ValueError('Module \'{}\' could not be imported' .format(module_path,))
#         return module
# 
#     def get_member(self, module, member_name):
#         try:
#             cls = getattr(module, member_name)
#         except AttributeError:
#             raise ValueError('Module \'{}\' has no member \'{}\''.format(module, member_name, ))
#         return cls
# 
#     def run_job(self, job):
#         job_module = self.get_module(job['module'])
#         job_func = self.get_member(job_module, job['function'])
#         job_args = [job['module'].rsplit('.', 1)[1]] + job['params'].split()
#         if not self.quiet:
#             print_ok('Executing \'{}\' ({}.{})'.format(job['name'], job['module'], job['function']))
#         job_func(job_args)
# 
#     def run(self):
#         doExit = False
#         while not doExit:
#             try:
#                 time_start = datetime.datetime.now()
#                 for job in self.config['jobs']:
#                     self.run_job(job)
# 
#                 print_ok('All jobs done [{}]'.format(datetime.datetime.now()-time_start))
# 
#                 if float(self.config['interval']) < 0:
#                     doExit = True
#                 else:
#                     time.sleep(float(self.config['interval']) * 60)
#             except KeyboardInterrupt:
#                 print('\b\b')
#                 print_ok('Aborted by user. Good bye!')
#                 doExit = True


from afl_utils import afl_cron, afl_sync
from afl_utils.afl_cron import AflCronDaemon
import os
import shutil
import unittest
            cron.get_module('invalid_module.path')

    def test_get_member(self):
        module = afl_sync
        cls = afl_sync.AflBaseSync
        cls_name = 'AflBaseSync'
        fcn = afl_sync.main
        fcn_name = 'main'

        # get class
        cron = AflCronDaemon(g_config_file)
        self.assertEqual(cls, cron.get_member(module, cls_name))

        # get func
        cron = AflCronDaemon(g_config_file)
        self.assertEqual(fcn, cron.get_member(module, fcn_name))

        # error case
        with self.assertRaises(ValueError):
            cron.get_member(module, 'invalid_class')

    def test_run_job(self):
        # TODO
        pass

    def test_run(self):
        # TODO
        pass

    def test_show_info(self):

# Path: afl_utils/afl_cron.py
# class AflCronDaemon(object):
#     def __init__(self, config_file, quiet=False):
#     def load_config(self, config_file):
#     def get_module(self, module_path):
#     def get_member(self, module, member_name):
#     def run_job(self, job):
#     def run(self):
# def show_info():
# def main(argv):
# 
# Path: afl_utils/afl_sync.py
# class AflBaseSync(object):
# class AflRsync(AflBaseSync):
#     def __init__(self, server_config, fuzzer_config):
#     def __init__(self, server_config, fuzzer_config):
#     def __prepare_rsync_commandline(self, local_path, remote_path, rsync_options=list(_rsync_default_options),
#                                     rsync_excludes=list([]), rsync_get=False):
#     def __invoke_rsync(self, rsync_cmdline):
#     def __get_fuzzers(self):
#     def rsync_put(self, local_path, remote_path, rsync_options=list(_rsync_default_options), rsync_excludes=list([])):
#     def rsync_get(self, remote_path, local_path, rsync_options=list(_rsync_default_options), rsync_excludes=list([])):
#     def push(self):
#     def pull(self):
#     def sync(self):
# def show_info():
# def main(argv):
# 
# Path: afl_utils/afl_cron.py
# class AflCronDaemon(object):
#     def __init__(self, config_file, quiet=False):
#         self.config = self.load_config(config_file)
#         self.quiet = quiet
# 
#     def load_config(self, config_file):
#         with open(config_file, 'r') as raw_config:
#             config = json.load(raw_config)
#         return config
# 
#     def get_module(self, module_path):
#         module_name = module_path.rsplit('.', 1)[1]
#         try:
#             module = __import__(module_path, fromlist=[module_name])
#         except ImportError:
#             raise ValueError('Module \'{}\' could not be imported' .format(module_path,))
#         return module
# 
#     def get_member(self, module, member_name):
#         try:
#             cls = getattr(module, member_name)
#         except AttributeError:
#             raise ValueError('Module \'{}\' has no member \'{}\''.format(module, member_name, ))
#         return cls
# 
#     def run_job(self, job):
#         job_module = self.get_module(job['module'])
#         job_func = self.get_member(job_module, job['function'])
#         job_args = [job['module'].rsplit('.', 1)[1]] + job['params'].split()
#         if not self.quiet:
#             print_ok('Executing \'{}\' ({}.{})'.format(job['name'], job['module'], job['function']))
#         job_func(job_args)
# 
#     def run(self):
#         doExit = False
#         while not doExit:
#             try:
#                 time_start = datetime.datetime.now()
#                 for job in self.config['jobs']:
#                     self.run_job(job)
# 
#                 print_ok('All jobs done [{}]'.format(datetime.datetime.now()-time_start))
# 
#                 if float(self.config['interval']) < 0:
#                     doExit = True
#                 else:
#                     time.sleep(float(self.config['interval']) * 60)
#             except KeyboardInterrupt:
#                 print('\b\b')
#                 print_ok('Aborted by user. Good bye!')
#                 doExit = True


# Path: tests/test_afl_cron.py
from afl_utils import afl_cron, afl_sync
from afl_utils.afl_cron import AflCronDaemon
import os
import shutil
import unittest

            cron.get_module('invalid_module.path')

    def test_get_member(self):
        module = afl_sync
        cls = afl_sync.AflBaseSync
        cls_name = 'AflBaseSync'
        fcn = afl_sync.main
        fcn_name = 'main'

        # get class
        cron = AflCronDaemon(g_config_file)
        self.assertEqual(cls, cron.get_member(module, cls_name))

        # get func
        cron = AflCronDaemon(g_config_file)
        self.assertEqual(fcn, cron.get_member(module, fcn_name))

        # error case
        with self.assertRaises(ValueError):
            cron.get_member(module, 'invalid_class')

    def test_run_job(self):
        # TODO
        pass

    def test_run(self):
        # TODO
        pass

    def test_show_info(self):

        self.assertIsNone(afl_cron.show_info())