예제 #1
0
def main():
    args = ArgParse.arg_parse()
    # args is [u, verbose, ns, l, format, silent]
    logger = Logger.get_logger(args.format, args.silent)
    if args:
        call_all(args.verbose, args.namespace, args.logging, logger)
        k8s.Output.time_taken(start_time)   
예제 #2
0
def main():
    urllib3.disable_warnings()
    args = ArgParse.arg_parse()
    # [help, action, body, format, kubeconfig, object_name, \
    # namespace, object, status, dryrun, loglevel, log_output_format]
    logger = Logger.get_logger(args.output, args.loglevel)
    k8s_config = KubeConfig.load_kube_config(args.output, \
                                logger, args.kubeconfig)
    if args.body:
        if 'json' in args.input:
            body = json.load(args.body[0])
        elif 'yaml' in args.input:
            body = yaml.load(args.body[0], yaml.Loader)
        else:
            logger.warning("Invalid format of patch body passed")
    else:
        body = ''
    call = MantaRay(logger, k8s_config, args.output)
    call.pod_crud_operations(args)
예제 #3
0
import unittest
import warnings
from modules.logging import Logger

logger = Logger.get_logger('', '')


class TestK8sClusterChecker(unittest.TestCase):
    def test_cluster(self):
        import cluster as cluster
        warnings.filterwarnings("ignore",
                                category=ResourceWarning,
                                message="unclosed.*<ssl.SSLSocket.*>")
        self.assertRaises(TypeError, cluster.call_all(True, True, logger),
                          True)
        with self.assertRaises(Exception) as x:
            print("Exception ignored: {}".format(x.exception))

    def test_nodes(self):
        import nodes as nodes
        warnings.filterwarnings("ignore",
                                category=ResourceWarning,
                                message="unclosed.*<ssl.SSLSocket.*>")
        with self.assertRaises(Exception) as x:
            print("Exception ignored: {}".format(x.exception))

    def test_namespace(self):
        import namespace as namespace
        warnings.filterwarnings("ignore",
                                category=ResourceWarning,
                                message="unclosed.*<ssl.SSLSocket.*>")
예제 #4
0
from modules.crawling import init_driver, Fetcher, Extractor
from modules.notification import NotificationController
from plugins.enabled import sites

# 目標動作時間を受け取る
uptime = int(sys.argv[1])

# 開始時刻を記録する
start = time.time()

# タスクキューを作成する
fetch_queue = Queue(conf.parallel * 2)
documents_queue = Queue()

# ロギングを開始する
logger = Logger()
logger.log_line("プロセスを開始しました。")
logger.commit()

# フェッチャーを起動する
drivers = []
try:
    for i in range(conf.parallel):
        drivers.append(init_driver())
except Exception as e:
    try:
        logger.log_exception(e, "フェッチャーの起動に失敗しました。")
        logger.commit()
    except:
        pass
    for driver in drivers: