Ejemplo n.º 1
0
def upgrade_box():
    global main_page_flag
    try:
        cur = time.localtime()
        if cur.tm_hour == 0:
            upgrade_info = download.repository.DownloadDao.get_upgrade_info({
                "type":
                "UPGRADE_BOX",
                "status":
                "finish"
            })
            if len(upgrade_info) == 0:
                return
            else:
                _upgrade_info = upgrade_info[0]
                if _upgrade_info["initFlag"] == 1:  # update and init client
                    Configurator.set_value("Upgrade", "initFlag", "1")

            while 1:
                if main_page_flag:
                    download.repository.DownloadDao.update_upgrade_info_for_deleteflag(
                        {"id": upgrade_info[0]["id"]})
                    os.system("upgradeIM.EXE")
    except Exception as e:
        logger.error(("upgrade_box ERROR :", e))
Ejemplo n.º 2
0
def set_version():
    global version
    conf_version = Configurator.get_value("Version", "version")
    if conf_version is None:
        Configurator.set_value("Version", "version", version)
    elif conf_version == version:
        return
    else:
        Configurator.set_value("Version", "version", version)
Ejemplo n.º 3
0
def upgrade_init():
    try:
        init_flag = Configurator.get_value("Upgrade", "initFlag", default=0)
        if init_flag == "1":
            logger.debug("start to init client ")
            init_client()
            logger.debug("init_client finish ")
            Configurator.set_value("Upgrade", "initFlag", "0")
        else:
            logger.debug("init flag is 0")
    except Exception as e:
        logger.error(("upgrade_init ERROR :", e))
Ejemplo n.º 4
0
def start():
    global cabinet_count, lock_machine_port, lock_version, buffer_range_count
    if Configurator.get_value("LockMachine", "cabinet_count"):
        cabinet_count = Configurator.get_value("LockMachine", "cabinet_count")
    try:
        lock_machine_port = serial.Serial(
            **ClientTools.get_port_value("LockMachine", 38400, 'COM2'))
        print("start lock_machine_port is:" + lock_machine_port)
        if lock_version == "1":
            buffer_range_count = 8
        elif lock_version == "2":
            buffer_range_count = 5
    except Exception as e:
        print(e)
        logger.warn(e)
Ejemplo n.º 5
0
def get_box():
    order_no = Configurator.get_value("ClientInfo", "OrderNo")
    param = {"orderNo": order_no, "deleteFlag": 0}
    box_list = BoxDao.get_box_by_order_no(param)
    if len(box_list) != 1:
        return False
    return box_list[0]
Ejemplo n.º 6
0
    def __init__(self, tab, c, e, db):
        """
		inizializza la gui di configurazione delle entita'
		@param string: classe o tab di appartenenza dell'entita' <'MARCHE'><'PARAMETRI'>
		@param Configurator:i
		@note: il valore del tab fa si che il testo delle entichette sopra le due liste sia adeguato all'entita'  
		inoltre la casella per la selezione del numero max di marche e' visibile esclusivamente se tab ='marche'
		"""
        label = {}
        self.entity = e
        self.configurator = c
        label['marche'] = [
            "CLASSI MARCHE DISPONIBILI", "CLASSI MARCHE SELEZIONATE"
        ]
        label['parametri'] = ["PARAMETRI DISPONIBILI", "PARAMETRI SELEZIONATI"]
        visible = {}
        visible['marche'] = True
        visible['parametri'] = False
        self.tab = tab.lower()
        QMainWindow.__init__(self, parent=None)
        self.w = Ui_Configurazione()
        self.setupUi(self)
        self.label.setText(label[self.tab][0])
        self.label_2.setText(label[self.tab][1])
        self.label_num.setVisible(visible[self.tab])
        self.spin_num.setVisible(visible[self.tab])
        #self.setWindowTitle("Configurazione "+self.tab.lower()+nomeDb.capitalize())
        self.db = db
        c = Configurator(self.tab, self.db)
        #genero la lista degli elementi selezionabili
        self.elementsList = []
        l = c.getAvailableElements(self.tab)
        for i in l:
            #print i
            e = EntityElement(
                i['Id'], self.tab,
                self.db)  # il costruttore richiede class_id e tab
            self.elementsList.append(e)
            #c.addElement()
        self.updateLists()
        self.connect(self.table_disp,
                     QtCore.SIGNAL("customContextMenuRequested(QPoint)"),
                     self.onContextDisp)
        self.connect(self.table_sel,
                     QtCore.SIGNAL("customContextMenuRequested(QPoint)"),
                     self.onContextSel)
Ejemplo n.º 7
0
 def __init__(self):
     Config = Configurator.Configurator()
     ConfiguredObject = Config.read_configuration()
     Section = "DB Section"
     parameter_dict = Config.get_parameters(ConfiguredObject, Section)
     self.host = parameter_dict['host']
     self.dbname = parameter_dict['dbname']
     self.user = parameter_dict['user']
     self.pwd = parameter_dict['password']
Ejemplo n.º 8
0
def settings():
    config = cf.Configurator()
    settings = config.BuildUIData()
    
    """Renders the about page."""
    return render_template(
        'settings.html',
        title='Settings',
        year=datetime.now().year,
        settings = settings,
        message='Update Settings Required for Application.'
    )
Ejemplo n.º 9
0
	def __init__(self,tab,c,e,db):
		"""
		inizializza la gui di configurazione delle entita'
		@param string: classe o tab di appartenenza dell'entita' <'MARCHE'><'PARAMETRI'>
		@param Configurator:i
		@note: il valore del tab fa si che il testo delle entichette sopra le due liste sia adeguato all'entita'  
		inoltre la casella per la selezione del numero max di marche e' visibile esclusivamente se tab ='marche'
		"""
		label={}
		self.entity=e
		self.configurator=c 
		label['marche']=["CLASSI MARCHE DISPONIBILI","CLASSI MARCHE SELEZIONATE"]
		label['parametri']=["PARAMETRI DISPONIBILI","PARAMETRI SELEZIONATI"]
		visible={}
		visible['marche']=True
		visible['parametri']=False
		self.tab=tab.lower()
		QMainWindow.__init__(self,parent=None)
		self.w=Ui_Configurazione()
		self.setupUi(self)
		self.label.setText(label[self.tab][0])
		self.label_2.setText(label[self.tab][1])
		self.label_num.setVisible(visible[self.tab])
		self.spin_num.setVisible(visible[self.tab])
		#self.setWindowTitle("Configurazione "+self.tab.lower()+nomeDb.capitalize())
		self.db=db
		c=Configurator(self.tab,self.db)
		#genero la lista degli elementi selezionabili
		self.elementsList=[]
		l=c.getAvailableElements(self.tab)
		for i in l:
			#print i
			e=EntityElement(i['Id'],self.tab,self.db)# il costruttore richiede class_id e tab
			self.elementsList.append(e)
			#c.addElement()
		self.updateLists()
		self.connect(self.table_disp,QtCore.SIGNAL("customContextMenuRequested(QPoint)"),self.onContextDisp)
		self.connect(self.table_sel,QtCore.SIGNAL("customContextMenuRequested(QPoint)"),self.onContextSel)	
		
		
Ejemplo n.º 10
0
def manager_get_box_info():
    box_info = get_box()
    box_info["operator_name"] = CompanyDao.get_company_by_id({"id": box_info["operator_id"]})[0]["name"]
    box_info["order_no"] = Configurator.get_value("ClientInfo", "OrderNo")
    box_info["token"] = Configurator.get_value("ClientInfo", "Token")
    # Scanner
    if Configurator.get_value("Scanner", "port"):
        box_info["scanner_port"] = Configurator.get_value("Scanner", "port")
    else:
        box_info["scanner_port"] = "None"
    # LockMachine
    if Configurator.get_value("LockMachine", "port"):
        box_info["lock_machine_port"] = Configurator.get_value("LockMachine", "port")
    else:
        box_info["lock_machine_port"] = "None"
    # UPS
    if Configurator.get_value("Ups", "port"):
        box_info["ups_port"] = Configurator.get_value("Ups", "port")
    else:
        box_info["ups_port"] = "None"

    box_signal_handler.manager_get_box_info_signal.emit(json.dumps(box_info))
Ejemplo n.º 11
0
def get_port_value(device_name,
                   default_baud_rate,
                   default_port,
                   default_timeout=1):
    if Configurator.get_value(device_name, "baudrate"):
        baudrate = Configurator.get_value(device_name, "baudrate")
    else:
        baudrate = default_baud_rate

    if Configurator.get_value(device_name, "port"):
        port = Configurator.get_value(device_name, "port")
    else:
        port = default_port

    if Configurator.get_value(device_name, "timeout"):
        timeout = Configurator.get_value(device_name, "timeout")
    else:
        timeout = default_timeout
    __result = {'baudrate': baudrate, 'port': port, 'timeout': timeout}
    logger.debug((device_name, __result))
    return __result
Ejemplo n.º 12
0
 def testGetValue(self):
     self.assertEqual(Configurator.get_value("CoinMachine", "port"), "com5")
     self.assertEqual(Configurator.get_value("CoinMachine", "None"), None)
     self.assertEqual(Configurator.get_value("None", "None"), None)
Ejemplo n.º 13
0
import logging

import requests

import Configurator
import box.service.BoxService

NOT_INTERNET_ = {'statusCode': -1, 'statusMessage': 'Not Internet'}

__author__ = 'gaoyang'

url = Configurator.get_value("ClientInfo", "ServerAddress")
order_no = Configurator.get_value("ClientInfo", "OrderNo")
box_token = Configurator.get_value("ClientInfo", "Token")
user_token = ""
disk_serial_number = ""

logger = logging.getLogger()


def set_user_token(token):
    global user_token
    user_token = token


def clean_user_token():
    global user_token
    user_token = ""


def get_header():
Ejemplo n.º 14
0
from Configurator import *

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
#* Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Configurator()
Ejemplo n.º 15
0

def mainMenu():
    os.system('cls')
    mode = 1
    while mode != 0:
        print(' Options: \n 1 - REF \n 2 - WCS Settings  \
        \n 3 - MDI \n 4 - JOG \n 5 - AUTO \n 6 - Machine Connection \n ')
        print('Select: ')
        mode = msvcrt.getch().decode('utf-8').lower()
        os.system('cls')
        if mode == '1':
            Functions.refMachine()
        if mode == '2':
            Functions.WCS_set()
        if mode == '3':
            Functions.MDI()
        if mode == '4':
            Functions.JOG()
        if mode == '5':
            Functions.AUTO()
        if mode == '6':
            machine.connection()

        mode = 0


Configurator.loadConfig()
while 1:
    mainMenu()
Ejemplo n.º 16
0
def main():
    print ('myPrint')
    myPrint()
    print
  
    Configurator.write_conf()
  
    print ('String: both_ends')
    cases = ast.literal_eval(Configurator.get_conf('String', 'both_ends'))
    for case in cases:
        print (case + ' -> ' + mystring.both_ends(case))
        print

    print ('String: fix_start')
    cases = ast.literal_eval(Configurator.get_conf('String', 'fix_start'))
    for case in cases:
        print (case + ' -> ' + mystring.fix_start(case))
        print
  
        print ('String: mix_up')
        cases = ast.literal_eval(Configurator.get_conf('String', 'mix_up'))
    for case in cases:
        print (case),
        print (' -> ' + mystring.mix_up(case[0], case[1]))
        print
  
    print ('String: not_bad')
    cases = ast.literal_eval(Configurator.get_conf('String', 'not_bad'))
    for case in cases:
        print (case + ' -> ' + mystring.not_bad(case))
    print
  
    print ('String: font_back')
    cases = ast.literal_eval(Configurator.get_conf('String', 'front_back'))
    for case in cases:
        print (case),
        print (' -> ' + mystring.front_back(case[0], case[1]))
    print
  
    print ('List: match_ends')
    cases = ast.literal_eval(Configurator.get_conf('List', 'match_ends'))
    for case in cases:
        print (case),
        print (' -> '),
        print (mylist.match_ends(case))
    print
  
    print ('List: front_x')
    cases = ast.literal_eval(Configurator.get_conf('List', 'front_x'))
    for case in cases:
        print (case),
        print (' -> '),
        print (mylist.front_x(case))
    print
  
    print ('List: sort_last')
    cases = ast.literal_eval(Configurator.get_conf('List', 'sort_last'))
    for case in cases:
        print (case),
        print (' -> '),
        print (mylist.sort_last(case))
    print
  
    print ('List: remove_adjacent')
    cases = ast.literal_eval(Configurator.get_conf('List', 'remove_adjacent'))
    for case in cases:
        print (case),
        print (' -> '),
        print (mylist.remove_adjacent(case))
    print
  
    print ('List: linear_merge')
    cases = ast.literal_eval(Configurator.get_conf('List', 'linear_merge'))
    for case in cases:
        print (case),
        print (' -> '),
        print (mylist.linear_merge(case[0], case[1]))
    print
  
    print ('Remote:')
    width = ast.literal_eval(Configurator.get_conf('Remote', 'width'))
    x = ast.literal_eval(Configurator.get_conf('Remote', 'x'))
    y = ast.literal_eval(Configurator.get_conf('Remote', 'y'))
    remote = remotekeypad.remotekeypad(width, x, y)
    cases = ast.literal_eval(Configurator.get_conf('Remote', 'keys'))
    for case in cases:
        remote.get_moves(case)
        print
Ejemplo n.º 17
0
def init_printer():
    global character_set, printer
    if Configurator.get_value("Printer", "character_set"):
        character_set = Configurator.get_value("Printer", "character_set")
    printer = serial.Serial(
        **ClientTools.get_port_value("Printer", 38400, 'COM3'))
Ejemplo n.º 18
0
 def setUp(self):
     Configurator.set_value("CoinMachine", "port", "com5")
Ejemplo n.º 19
0
import time

import Configurator
import ClientTools
import codecs
import serial

__author__ = 'gaoyang'

lock_machine_port = None
cabinet_count = 16
door_count = 24
lock = threading.Lock()
logger = logging.getLogger()
lock_version = Configurator.get_or_set_value("LockMachine",
                                             "version",
                                             default="1")
buffer_range_count = ""


class LockMachineHandler(QObject):
    open_door_result = pyqtSignal(str)


def start():
    global cabinet_count, lock_machine_port, lock_version, buffer_range_count
    if Configurator.get_value("LockMachine", "cabinet_count"):
        cabinet_count = Configurator.get_value("LockMachine", "cabinet_count")
    try:
        lock_machine_port = serial.Serial(
            **ClientTools.get_port_value("LockMachine", 38400, 'COM2'))
Ejemplo n.º 20
0
def WCS_set():
    selected_WCS = 1
    while selected_WCS != 'r':
        print('WCSs: \n 4 - G54 \n 5 - G55 \n 6 - G56 \n')
        print('Select WCS to configure: (R  to return)')

        selected_WCS = msvcrt.getch().decode('utf-8').lower()
        os.system('cls')
        #print(selected_WCS)
        #time.sleep(5)
        if selected_WCS == '4':

            option = 1
            while option != 'r':

                print('G54: \n     X : %.3f \n     Y : %.3f \n     Z : %.3f' %
                      (machine.G54[0], machine.G54[1], machine.G54[2]))
                print('\n Select axis : (R to return)')
                option = msvcrt.getch().decode('utf-8').lower()
                if option == 'x':
                    print('x : ')
                    offset = input()
                    if offset != '':
                        machine.G54[0] = (machine.machine_pos[0] -
                                          float(offset))
                elif option == 'y':
                    print('y : ')
                    offset = input()
                    if offset != '':
                        machine.G54[1] = (machine.machine_pos[1] -
                                          float(offset))
                elif option == 'z':
                    print('z : ')
                    offset = input()
                    if offset != '':
                        machine.G54[2] = (machine.machine_pos[2] -
                                          float(offset))
                os.system('cls')

        elif selected_WCS == '5':

            option = 1
            while option != 'r':
                print('G55: \n     X : %.3f \n     Y : %.3f \n     Z : %.3f' %
                      (machine.G55[0], machine.G55[1], machine.G55[2]))
                print('\n Select axis : (R to return)')
                option = msvcrt.getch().decode('utf-8').lower()
                if option == 'x':
                    print('x : ')
                    offset = input()
                    if offset != '':
                        machine.G55[0] = (machine.machine_pos[0] -
                                          float(offset))
                elif option == 'y':
                    print('y : ')
                    offset = input()
                    if offset != '':
                        machine.G55[1] = (machine.machine_pos[1] -
                                          float(offset))
                elif option == 'z':
                    print('z : ')
                    offset = input()
                    if offset != '':
                        machine.G55[2] = (machine.machine_pos[2] -
                                          float(offset))

        elif selected_WCS == '6':

            option = 1
            while option != 'r':
                print('G56: \n     X : %.3f \n     Y : %.3f \n     Z : %.3f' %
                      (machine.G56[0], machine.G56[1], machine.G56[2]))
                print('\n Select axis : (R to return)')
                option = msvcrt.getch().decode('utf-8').lower()
                if option == 'x':
                    print('x : ')
                    offset = input()
                    if offset != '':
                        machine.G56[0] = (machine.machine_pos[0] -
                                          float(offset))
                elif option == 'y':
                    print('y : ')
                    offset = input()
                    if offset != '':
                        machine.G56[1] = (machine.machine_pos[1] -
                                          float(offset))
                elif option == 'z':
                    print('z : ')
                    offset = input()
                    if offset != '':
                        machine.G56[2] = (machine.machine_pos[2] -
                                          float(offset))
        Configurator.saveConfig()
        os.system('cls')
Ejemplo n.º 21
0
 def testSetValue(self):
     Configurator.set_value("None Section", "None Option", "None Value")
     self.assertEqual(Configurator.get_value("None Section", "None Option"),
                      "None Value")