Ejemplo n.º 1
0
    def initialize(self):
        tools.log_app_info('[{}] Starting learner with {}'.format(
            self.room_id, self.config_filename))
        ##  read config
        self.config = tools.read_config(self.config_filename)
        self.code_manager = CodeManager(self.config['code'])
        ## init a Logger
        self.logger = logging_tools.Logger()
        self.logger.log_new_connnection(self.client_ip, self.user_agent,
                                        self.room_id, self.config_filename,
                                        self.config)
        tools.log_app_info('[{}] Started Logger at {}'.format(
            self.room_id, self.logger.log_folder))
        ## request url displayed on page
        self.request_url_info()
        ## make sure pad is loaded before starting
        self.init_pad()
        ## init timeout configuration
        self.init_timeout()
        ## initialize the algortihm
        tools.log_app_info('[{}] Initializing learner...'.format(self.room_id))
        self.init_learner()
        tools.log_app_info('[{}] Learner initialized.'.format(self.room_id))

        ## make sure all element are correctly displayed
        self.classifier_info_last_solved = None
        self.n_iteration_at_last_solved = 0
        self.update_iteration(new_iteration_value=0)
        self.update_code(apply_pause=False)
        #
        self.clean_pad()
        self.update_pad()
        self.update_hood()
        self.update_flash_pattern()
Ejemplo n.º 2
0
 def reset(self):
     ## save before reseting if applicable
     # self.logger.log_on_reset()
     ## reset procedure
     print('[{}] Starting learner from {}'.format(self.room_id, self.config_filename))
     self.config = read_config(self.config_filename)
     self.code_manager = CodeManager(self.config['code'])
     self.init_learner()
     self.start()
Ejemplo n.º 3
0
    def __init__(self,
                 host: str,
                 port: int,
                 index: str = "",
                 dropbox: bool = False,
                 verbose: bool = True,
                 dryrun: bool = False):
        self._folder = data.Folder()
        self._dropbox = dropbox
        self._verbose = verbose
        self._dryrun = dryrun
        self._connection = elastic.Connection(host, port)
        if index:
            self._connection.index = index
        self._store = elastic.Store(self._connection)
        self._delete = elastic.Delete(self._connection)
        self._dbox = data.DBox(True)

        config = read_config()
        self._nas_root = config['nas_root']
        self._dropbox_root = config['dropbox_root']
Ejemplo n.º 4
0
if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description="""Scan both locations using os.listdir, which is fast.
    Make use of the fact that Dropbox creates the dir entries locally. Check if both copies exist,
    create output files with one line each for items that are on only nas, or only dropbox.
    Running this only makes sense if the sync between the two does not return anything to sync."""
    )
    parser.add_argument('year',
                        nargs='?',
                        type=str,
                        help='Which year dir to check.')
    root_arguments(parser)
    args = parser.parse_args()

    config = read_config()
    nas_root = config['nas_root']
    dropbox_root = config['dropbox_local']
    if args.year:
        nas_root = os.path.join(nas_root, args.year)
        dropbox_root = os.path.join(dropbox_root, args.year)

    walktree(nas_root, nas_list, len(nas_root))
    loading_bar = 0
    print(' ')
    walktree(dropbox_root, dropbox_list, len(dropbox_root))
    print(' ')

    nas_list = sorted(nas_list)
    dropbox_list = sorted(dropbox_list)
    nas_only = []
Ejemplo n.º 5
0
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.header import Header
import os
import sys
path = os.getcwd().split('cassia_automation')[0] + 'cassia_automation/lib/'
sys.path.append(path)
from tools import read_config

conf = read_config()['mail_attr']


class send_report():
    def __init__(self, comment):
        self.mail_host = conf['mail_host']
        self.mail_port = conf['mail_port']
        self.mail_user = conf['mail_user']
        self.mail_pass = conf['mail_pass']
        self.mail_sender = conf['mail_sender']
        self.mail_recv = eval(conf['mail_recv'])
        self.mail_text = comment

    def write_mail(self):
        # 创建一个带附件的实例
        self.message = MIMEMultipart()
        self.message['From'] = Header("自动化测试平台", 'utf-8')
        self.message['To'] = Header(",".join(self.mail_recv), 'utf-8')