def _map_scan_cfg(self):
        if self.args.cfg:
            self.cfg_path = self.args.cfg
        for map_n in self.args.scan:
            cfg = ConfigLoader(self.cfg_path + '/' + map_n + '.cfg')
            cfg.load()
            map_data = cfg.zbx.scan_map(map_n)
            scan_map = ConfigCreate(map_data, cfg.zbx)
            scan_map.create()
            scan_map.check_map(self.cfg_path)
            scan_map.save(self.cfg_path)

            del cfg, scan_map, map_data
Beispiel #2
0
def main(config_path):
    t0 = time.clock()
    config_loader = ConfigLoader(config_path)
    args = config_loader.load()
    config = Config(args)

    inference_img = config.get_inference_img_path()
    threshold = config.get_inference_threshold()

    output = os.path.join(ROOT_FOLDER, config.get_inference_output())

    similarities = Similarities(config.get_same_region_path())
    saliency = Saliency(config.get_salience_path())
    fusion = Fusion(config.get_fusion_path(), config.get_fusion_model_type())

    similarities_model = similarities.get_model()

    img_data = Img_Data(inference_img)

    X = saliency.inference(img_data, similarities_model)
    Y = fusion.inference(X, img_data)
    cv2.imwrite("mask.png", Y)
    Y = grabcut_inference(inference_img, Y)
    # Y = inference(cv2.imread(inference_img), Y)
    cv2.imwrite("mask_postprocess.png", Y)
    result_img = get_transparent_image(inference_img, Y, threshold)
    if os.path.isdir(output) is False:
        os.mkdir(output)
    img_name = inference_img.split("/")[-1].split(".")[0]
    result_path = output + img_name + ".png"
    cv2.imwrite(result_path, result_img)
    print("finished~( •̀ ω •́ )y")
    t1 = time.clock() - t0
    print("Time elapsed: ", t1)
    def _map_img(self):
        if self.args.cfg:
            self.cfg_path = self.args.cfg
        if self.args.img:
            self.img_path = self.args.img
        for map_fn in self.args.map:
            cfg = ConfigLoader(self.cfg_path + '/' + map_fn)
            cfg.load()
            map_obj = cfg.create_map(self.font_path_fn, self.icon_path)
            map_obj.do()
            # map_obj.show()
            map_obj.save_img(self.img_path + '/' + map_fn[:-4] + '.png')

            if self.args.upload:
                cfg.upload(self.img_path + '/' + map_fn[:-4] + '.png')

            del cfg, map_obj
Beispiel #4
0
import logging.config
import os

import yaml

from config import ConfigLoader
from sync import Sync
from util import read_file
from worker import Worker

# Load all properties from INI and point to the folder where resources are stored
props_file = "app.ini"
cl = ConfigLoader.load(props_file, 'sync_resource')

# Just for process output
with open("logging.yml") as log_cfg:
    logging.config.dictConfig(yaml.safe_load(log_cfg))

sync_options = cl.get_config('sync')
resources_config = cl.get_resource_config()
log_folder = sync_options.get("log_folder")
os.makedirs(log_folder, exist_ok=True)

# The "base" config into which sync config gets merged
template_config = resources_config.merge_with(sync_options.values)
template_config.set_value("log_folder", os.path.abspath(log_folder))

# Read in the set of example syncs
example_sync_data = read_file("../example_sync/example.yml")

# Execute (single thread for now)
Beispiel #5
0
import config.Logger as logging
from tasks import RealTimeTasks, SleepUntilTomorrow
import reporters.PushBulletManager as pbm
import time

log = logging.getLogger()
log.info("Initializing RTSN")

symbols = []
# Map of stocks by symbol
stocks = {}
# Map of rules by symbol
rules = {}

rules = RuleLoader.load()
config = configurer.load()

for symbol in rules:
    symbols.append(symbol)

log.debug("loaded Rules for " + str(symbols))
tasks = []

pb = pbm.create(config["push-bullet-api-key"])

while True:
    time.sleep(SleepUntilTomorrow.getTimeSecondsUntilNextOpening())
    for symbol in symbols:
        task = RealTimeTasks.Task(symbol, symbol, config["refresh-time"], rules[symbol], pb)
        tasks.append(task)
        task.start()