Exemplo n.º 1
0
    def run(self):

        try:
            self._prepare.create_folder()
            StepTimes().add(
                'preparation_start'
            )  # TODO writes to old directory because does not exist yet
            Info().status = "preperation_start"
            self._prepare.execute()
            logging.info('End of Preparation')

            #StepTimes().add('preparation_start')
            StepTimes().add('simulation_start')
            logging.info('Start of simulation')
            self._system_monitor.start()
            self._event.execute(
                timeout=25)  # TODO check if timeout works as expected
            self._system_monitor.exit()
            logging.info('End of simulation')

            StepTimes().add('postprocessing_start')
            self._postprocessing.execute()
            StepTimes().add('postprocessing_end')

        except Exception as exce:
            Info().status = f"failed with {exce}"
            self._postprocessing.clean_up_docker_safe()
            raise exce
Exemplo n.º 2
0
def updateuser(username, userright, userwrong, usertimeduring, userchoicelog):
    userid = db.session.query(
        User.user_id).filter(User.user_username == username).first()
    if userid:
        userid = userid[0]
        lastlog = db.session.query(UserLog).filter(
            and_(UserLog.userlog_userid == userid,
                 UserLog.userlog_status == 0)).first()
        if lastlog:
            db.session.query(UserLog).filter(
                UserLog.userlog_userid == userid, ).update(
                    {"userlog_status": 1})
        userlog_userid = userid
        userlog_right = userright
        userlog_wrong = userwrong
        userlog_timeduring = usertimeduring
        userlog_status = 0
        userlog_choicelog = userchoicelog
        ul = UserLog(userlog_userid, userlog_right, userlog_wrong,
                     userlog_timeduring, userlog_status, userlog_choicelog)
        try:
            db.session.add(ul)
            db.session.commit()
        except Exception as e:
            print(e)
            return Info(False, "考试数据提交失败,请联系系统管理员!(" + str(userlog_choicelog) +
                        ")").todict()
        else:
            return Info(True, "考试数据提交成功", {
                "userlog_timeduring": userlog_timeduring
            }).todict()
    else:
        return Info(False, "非法的用户名").todict()
Exemplo n.º 3
0
def main(): 
    f = Figlet(font='slant')
    print(f.renderText('kracca'))
    if len(sys.argv) == 1:
        hlp()
        exit()
    else: 
        if sys.argv[1] == "--enterprise": 
            print("====ENTERPRISE MODE====")
        elif sys.argv[1] == "--personal": 
            print("====PERSONAL MODE====")
        if sys.argv[1] == "--help": 
            hlp()
            exit()
    if len(sys.argv) == 6: 
        result  = sys.argv[2] 
        keywords = sys.argv[3] 
        keynums = sys.argv[4]
        pooltxt = sys.argv[5]
        if sys.argv[1] == "--enterprise": 
            i = Info(name=input("name: "), currentyear=input("current year: "), address=input("address: "), motto=input("motto: "), phone=input("phone: "), email=input("email: "), mode="--enterprise")
        elif sys.argv[1] == "--personal":
            i = Info(name=input("name: "), aliases=input("aliases: "),address=input("address: "), phone=input("phone: "), email=input("emails: "), family=input("family names: "), mode="--personal")
    elif len(sys.argv) == 7:
        result  = sys.argv[2] 
        keywords = sys.argv[3] 
        keynums = sys.argv[4]
        pooltxt = sys.argv[5]
        filter1 = sys.argv[6]
        if filter1 == "--caps-only":
            if sys.argv[1] == "--enterprise": 
                i = Info(name=input("name: "), currentyear=input("current year: "), address=input("address: "), motto=input("motto: "), phone=input("phone: "), email=input("email: "), mode="--enterprise", capitalfilter=filter1 )
            elif sys.argv[1] == "--personal":
                i = Info(name=input("name: "), aliases=input("aliases: "),address=input("address: "), phone=input("phone: "), email=input("emails: "), family=input("family names: "), mode="--personal", capitalfilter=filter1)
        elif filter1 == "--with-nums": 
            if sys.argv[1] == "--enterprise": 
                i = Info(name=input("name: "), currentyear=input("current year: "), address=input("address: "), motto=input("motto: "), phone=input("phone: "), email=input("email: "), mode="--enterprise", numberfilter=filter1)
            elif sys.argv[1] == "--personal":
                i = Info(name=input("name: "), aliases=input("aliases: "),address=input("address: "), phone=input("phone: "), email=input("emails: "), family=input("family names: "), mode="--personal", numberfilter=filter1) 
    elif len(sys.argv) == 8: 
        result  = sys.argv[2] 
        keywords = sys.argv[3] 
        keynums = sys.argv[4]
        pooltxt = sys.argv[5]
        filter1 = sys.argv[6]
        filter2 = sys.argv[7]
        if filter1 == "--caps-only":
            if sys.argv[1] == "--enterprise": 
                i = Info(name=input("name: "), currentyear=input("current year: "), address=input("address: "), motto=input("motto: "), phone=input("phone: "), email=input("email: "), mode="--enterprise", capitalfilter=filter1, numberfilter=filter2)
            elif sys.argv[1] == "--personal":
                i = Info(name=input("name: "), aliases=input("aliases: "),address=input("address: "), phone=input("phone: "), email=input("emails: "), family=input("family names: "), mode="--personal", capitalfilter=filter1, numberfilter=filter2)
        elif filter1 == "--with-nums": 
            if sys.argv[1] == "--enterprise": 
                i = Info(name=input("name: "), currentyear=input("current year: "), address=input("address: "), motto=input("motto: "), phone=input("phone: "), email=input("email: "), mode="--enterprise", numberfilter=filter1, capitalfilter=filter2)
            elif sys.argv[1] == "--personal":
                i = Info(name=input("name: "), aliases=input("aliases: "),address=input("address: "), phone=input("phone: "), email=input("emails: "), family=input("family names: "), mode="--personal", numberfilter=filter1, capitalfilter=filter2) 
    print("bl1ng bl1ng i c u ;)")
    i.generate(result, keywords, keynums, pooltxt)
Exemplo n.º 4
0
def removeproblems(problem_id):
    pr = db.session.query(Problem).filter(
        Problem.problem_id == problem_id).first()
    if pr:
        db.session.delete(pr)
        db.session.commit()
        return Info(True, "删除成功!").todict()
    else:
        return Info(False, "不存在的题号!").todict()
Exemplo n.º 5
0
def initstudents():
    try:
        db.session.query(UserLog).update({"userlog_status": 1})
        db.session.commit()
    except Exception as e:
        print(e)
        return Info(False, "初始化失败!" + str(e)).todict()
    else:
        return Info(True, "初始化成功!").todict()
Exemplo n.º 6
0
def studentregitster(username, password):
    us = db.session.query(User).filter(
        User.user_username == username, ).first()
    if us:
        return Info(False, "已存在的用户名!").todict()
    else:
        user = User(username, password)
        db.session.add(user)
        db.session.commit()
        return Info(True, "注册成功!").todict()
Exemplo n.º 7
0
def modifypassword(oldpassword, newpassword, username):
    ad = db.session.query(Admin).filter(
        and_(Admin.admin_username == username,
             Admin.admin_password == oldpassword)).first()
    if not ad:
        return Info(False, "原密码错误!").todict()
    else:
        db.session.query(Admin).filter(
            Admin.admin_username == username).update(
                {"admin_password": newpassword})
        db.session.commit()
        return Info(True, "密码修改成功!").todict()
Exemplo n.º 8
0
def write2txt(result):
    inf = Info("Sorting result")
    inf.out_start()
    result = sorted(result, key=lambda x: x.index)
    inf.out_end()
    f = open('./reslut.txt', 'w')
    e = Info("Save result")
    e.out_start()
    for i in result:
        s = str(i.index) + ' ' + i.ip + ' ' + i.port + ' ' + i.state
        f.write(s)
        f.write('\n')
    f.close()
    e.out_end()
Exemplo n.º 9
0
Arquivo: widget.py Projeto: Xifax/tuci
    def __init__(self, parent=None):
        super(Widget, self).__init__(parent)

        # Initialize base gui widgets and objects
        self.text, self.info = Text(self), Info()
        self.clip = QApplication.clipboard()

        # Initialize composition
        self.compose({
            QHBoxLayout(): [self.text, self.info]
        })

        # Initialize events
        self.clip.dataChanged.connect(self.clipped)

        # Initialize styles and position
        self.widgetize('Tuci')
        #self.setAttribute(Qt.WA_TranslucentBackground) # remove this
        #self.setAttribute(Qt.WA_NoSystemBackground)  # remove this too
        self.setAutoFillBackground(True)
        # Either this, or use transparent png as a mask
        # TODO: move into widgetize()
        self.setWindowOpacity(0.85)
        # Move to separate qss stylesheet
        # SEE: http://homyakovda.blogspot.ru/2011/04/blog-post.html
        self.setStyleSheet('''
        QWidget {
          background-color: #a0b0d0;
          border: 2px solid white;
        }
        ''')
        #self.position()
        self.scale()
Exemplo n.º 10
0
Arquivo: main.py Projeto: heekim1/MH
    def __init__(self,
                 bam,
                 bed,
                 info,
                 out,
                 analytical_threshold=ANALYTICAL_THRESHOLD):

        self.bam = bam
        self.bed = bed
        self.info = info
        self.out = out
        self.analytical_threshold = analytical_threshold

        # Init
        self.bed_obj = Bed(self.bed)
        self.info_obj = Info(self.info)
        self.mh_dict = {}
        self.filters_obj = Filters(
            analytical_threshold=self.analytical_threshold,
            abs_analytical_threshold=self.ABSOLUTE_ANALYTICAL_THRESHOLD,
            min_mapq=self.MIN_MAPPING_QUALITY,
            max_mapq=self.MAX_MAPPING_QUALITY,
            remove_deletions=self.REMOVE_DELETIONS)
        self.short_reads_count = 0
        self.total_reads_count = 0
        self.number_of_contributors_overall = 0
Exemplo n.º 11
0
 def info(self, instance):
     home_screen = APP.root.current_screen
     from info import Info
     self.info = Info()
     APP.root.add_widget(self.info)
     APP.root.current = "info"
     APP.root.remove_widget(home_screen)
Exemplo n.º 12
0
    def build(self):
        manager = ScreenManager()

        manager.add_widget(Login(name='login'))
        manager.add_widget(Incorrect(name='incorrect'))
        manager.add_widget(Gallery(name='gallery'))

        manager.add_widget(Info(name='porsche'))
        manager.add_widget(Info(name='lotus'))
        manager.add_widget(Info(name='chevrolet'))
        manager.add_widget(Info(name='alfaromeo'))

        manager.add_widget(Stopwatch(name='stopwatch'))
        manager.add_widget(Calculator(name='calculator'))

        return manager
Exemplo n.º 13
0
def main():
    output_type = "brief"  # default

    #Print the welcome message:
    print("Welcome to this searcher!")
    print("To quit, please enter ::quit")

    conn = Connection()
    conn.connect()
    cursors = conn.get_cursors()

    quit = False

    while not quit:
        query = input("(Searcher)>>> ").lower()

        if query == "::quit":
            print("Thank you for using our service")
            conn.close()
            break

        elif query == "output=breif":
            output_type = "brief"

        elif query == "output=full":
            output_type = "full"

        else:
            try:
                info = Info(query, cursors, output_type)
                info.execute_query()

            except Exception:
                print("No matches found!")
Exemplo n.º 14
0
def OneCnn():
    brain = Brain()
    brain = brain.getInstance('cnn', 'log/cat_vs_dog/train/')
    from info import Info
    info = Info()
    image_info = info.getOneImage('data/cat_vs_dog/test/dog.9712.jpg')
    brain.evaluateOneImage(image_info, 2, {'cat': 0, 'dog': 1})
Exemplo n.º 15
0
 def __init__(self):
     # initializes game session and builds game resourses
     pygame.init()
     self.settings = Settings()
     # storing game statistics
     self.stats = Stats(self)
     self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
     self.screen_rect = self.screen.get_rect()
     self.settings.screen_width = self.screen.get_rect().width
     self.settings.screen_height = self.screen.get_rect().height
     pygame.display.set_caption("Warplanes")
     self.bg_color = self.settings.bg_colour
     self.hp = self.settings.enemy_hp
     self.junkers = Junkers(self)
     self.shots = pygame.sprite.Group()
     self.enemy_shots = pygame.sprite.Group()
     self.enemies = pygame.sprite.Group()
     # game scoreboard
     self.sb = Scoreboard(self)
     self.play_button = Button(self, "START", (0, -100))
     self.info_button = Button(self, "INFO", (0, 100))
     self.pause_button = Button(self, "Continue")
     self._create_sky()
     self.info = Info(self)
     pygame.mixer.music.load('music.wav')
     self.shot_sound = pygame.mixer.Sound('shot.ogg')
     self.explosion_sound = pygame.mixer.Sound('explosion.ogg')
Exemplo n.º 16
0
def load_excel():
    s = Info("Import excle")
    s.out_start()
    wb = openpyxl.load_workbook('/Users/kiana/Desktop/1.xlsx')
    sheet = wb.active
    s.out_end()
    return sheet
Exemplo n.º 17
0
 def __create_reciever__(self):
     # Немного странно, но ладно
     count_receivers = self.receivers(SIGNAL('html_sended(QString)'))
     if count_receivers == 0:
         info = Info()
         self.html_sended.connect(info.print_html)
         WindowsController.controller().open_window(info)
Exemplo n.º 18
0
 def entrust(self):
     """委托单
     委托状态:已报、部成、已报待撤、部成待撤、未报、待报、已成、已撤、部撤、废单
     """
     info = Info('entrust', self.broker)
     information = self.user.entrust()
     info.format(information)
     return info
Exemplo n.º 19
0
 def __init__(self):
     self.commans = (Play(), Variable(), Speech(), Info())  #, Sinoptik())
     self.db = DBConnector()
     # Очищаем список команд. Список не актуален.
     self.db.IUD("delete from core_execute")
     self.last_processed_ID = -1
     self.db.commit()
     self.run()
Exemplo n.º 20
0
def long_strategy(symbol):
    score = 0
    current_price = Info(symbol).get_current_price(symbol)
    previous_price = Info(symbol).get_previous_price(symbol)

    print('\n')
    print(symbol)
    print('--------------------------------')
    print('Valid: ')

    if current_price > previous_price:
        score += 1
        print(f'{score}. current_price > previous_price ')

    if score >= 1:  # Need to edit to '>=3'
        print('--------------------------------')
        open_order.long_order(symbol, current_price)
Exemplo n.º 21
0
    def selected(self):
        items = self.tableWidget.selectedItems()
        if not items:
            return
        self.tableWidget.clearSelection()

        self.inf = Info(items[0].data(QtCore.Qt.UserRole))
        self.inf.show()
Exemplo n.º 22
0
def trainFace():
    from info import Info
    info = Info()
    info.getMyFace()
    info.setOtherFace()
    brain = Brain()
    brain = brain.getInstance('face')
    brain.faceTrain()
Exemplo n.º 23
0
def trainCnn():
    brain = Brain()
    brain = brain.getInstance('cnn', 'log/cat_vs_dog/train/')
    train_dir = 'data/cat_vs_dog/train/'
    from info import Info
    info = Info()
    train_batch, train_label_batch = info.getImages(train_dir, {'cat' : 0, 'dog' : 1})
    brain.trainCnnNetwork(train_batch, train_label_batch)
Exemplo n.º 24
0
def getOutorgas():
	collection = db.dados_outorga
	documents = collection.find()
	infosOutorgas = []
	for document in documents:
		outorga = Info(document['ideGeracaoDistribuida'], document['nomGeracaoDistribuida'], str(document['mesReferencia']) + '-' + str(document['anoReferencia']), document['mdaPotenciaInstaladakW'], document['dthProcessamento'])
		infosOutorgas.append(outorga)
	return infosOutorgas	
Exemplo n.º 25
0
def close_order():
    for each in my_portfolio:
        symbol = each['symbol']
        percentage = round(Info(symbol).get_current_price(
            symbol) / each['price'], 2)
        if percentage >= 1.02:
            # still need to add a close order action
            my_portfolio.remove(each)
            print(f'ORDER CLOSED: {symbol}, {percentage} %')
Exemplo n.º 26
0
    def generate_info(self, id_info):
        analytics = initialize_analytics_reporting()

        info = Info()
        info.set_id(id_info)

        if id_info == 1:
            try:
                request = get_request('7daysAgo')
                response = get_report(request, analytics, id_info)
                number_of_user_last_week = response.get("reports")[0].get(
                    "data").get("rows")[0].get("metrics")[0].get("values")[0]
                info.set_first_line("SEMAINE DERNIERE")
                info.set_second_line(
                    str(number_of_user_last_week) + " utilisateurs")
            except:
                logging.error(
                    "Erreur lors de la recuperation des visiteurs de la semaine dernière"
                )

        elif id_info == 2:
            try:
                request = get_request('30daysAgo')
                response = get_report(request, analytics, id_info)
                number_of_user_last_week = response.get("reports")[0].get(
                    "data").get("rows")[0].get("metrics")[0].get("values")[0]
                info.set_first_line("MOIS DERNIER")
                info.set_second_line(
                    str(number_of_user_last_week) + " utilisateurs")
            except:
                logging.error(
                    "Erreur lors de la recuperation des visiteurs du mois dernier"
                )

        elif id_info == 3:
            ip = get_ip_address()
            info.set_first_line(datetime.now().strftime('%b %d  %H:%M:%S\n'))
            info.set_second_line('IP {}'.format(ip))

        elif id_info == 4:
            hostname = "apero-tech.fr"
            http_status_of_host = requests.get("https://" +
                                               hostname).status_code
            if http_status_of_host == 200:
                info.set_first_line(hostname)
                info.set_second_line("Est up :)")
                info.set_telegram_message("Le site est de nouveau en ligne!")
            else:
                info.set_first_line(hostname)
                info.set_second_line("Est down !! :(")
                info.set_level("ERROR")
                info.set_telegram_message("@Vinvin27 Le site est down!!")
                logging.error(hostname + "est down!")

        else:
            logging.error("L'info n'existe pas")
        return info
Exemplo n.º 27
0
 def check_available_cancels(self, parsed=True):
     """
     @Contact: Emptyset <*****@*****.**>
     检查撤单列表
     """
     info = Info('entrust', self.broker)
     information = self.user.check_available_cancels(parsed)
     info.format(information)
     return info
Exemplo n.º 28
0
def get_ip_list(sheet):
    ip_list = []
    s = Info("Get IP list")
    s.out_start()
    for ip in sheet.iter_rows(2, sheet.max_row):
        ip_list.append(ip[0].value)
        # print(ip[0].value)
    s.out_end()
    return ip_list
Exemplo n.º 29
0
 def __init__(self, element, server):
     self.server = server
     self.element = element
     self.type = "episode"
     # Get infor of object
     info = Info(self, server).info
     # Add value of info[k] to property named as the value of k  
     for k in info:
         setattr(self, k,  info[k])
Exemplo n.º 30
0
    def __init__(self):
        self.window = Tk()
        self.window.protocol("WM_DELETE_WINDOW", self.finishApp)
        self.window.title('Herramienta de prueba para la predicción')
        ico = PhotoImage(file=os.path.abspath('.') + '/Activos/term.png')
        self.window.call('wm', 'iconphoto', self.window._w, ico)
        self.window.config(bg=mainColor)
        self.window.attributes("-zoomed", False)
        self.window.minsize(width=300, height=300)

        #Peso 100% en self.window
        self.window.grid_rowconfigure(0, weight=1)
        self.window.grid_columnconfigure(0, weight=1)

        #Ventana principal fija sin ajuste de tamaño
        self.window.resizable(False, False)

        #Centrar ventana en función de las dimendsiones del contenedor de inicio
        self.center(450, 490)

        self.view = Window(self.window)
        self.functions = Functions()

        self.infoW = Info(self.view.dataContainer)
        self.genDataW = GenData(self.view.dataContainer)
        self.predW = Predictions(self.view.dataContainer)
        self.graphsW = Graphs(self.view.dataContainer)

        #Botones de las acciones del usuario
        self.view.buttonDisconnect.bind("<Button>", self.disconnect)
        self.view.buttonToBD.bind("<Button>", self.changeToConnect)
        self.view.buttonConnect.bind("<Button>", self.checkConnection)
        self.view.infoButton.bind(
            "<Button>", lambda event: self.switchSelector(
                self.view.predButton, self.view.graphButton, self.view.
                genDataButton, self.view.infoButton, 1))
        self.view.genDataButton.bind(
            "<Button>", lambda event: self.switchSelector(
                self.view.infoButton, self.view.predButton, self.view.
                graphButton, self.view.genDataButton, 2))
        self.view.predButton.bind(
            "<Button>", lambda event: self.switchSelector(
                self.view.infoButton, self.view.graphButton, self.view.
                genDataButton, self.view.predButton, 3))
        self.view.graphButton.bind(
            "<Button>", lambda event: self.switchSelector(
                self.view.infoButton, self.view.genDataButton, self.view.
                predButton, self.view.graphButton, 4))
        self.genDataW.buttonFilterData.bind("<Button>",
                                            lambda event: self.getNewGenData())
        self.graphsW.buttonGetGraph.bind("<Button>",
                                         lambda event: self.getGraphsData())
        self.predW.buttonForecast.bind("<Button>", self.getForecast)
        self.predW.butHistForecast.bind("<Button>", self.getHistForecast)

        #Ventana principal actualizaciones
        self.window.mainloop()