def buildConfigurations(self): ccd = ccdesign(len(self.paramsValues), center=(1, 0), face="ccf") for indexCCD, itemCCD in enumerate(ccd): conf = [] for indexRow, itemRow in enumerate(itemCCD): parameterValues = self.paramsValues[indexRow] # value == 1 --> MAXValue of the corresponding parameter if itemRow == 1: conf.append(parameterValues[-1]) # value == -1 --> minValue of the corresponding parameter elif itemRow == -1: conf.append(parameterValues[0]) # value == 0 --> medianValue of the corresponding parameter elif itemRow == 0: conf.append( parameterValues[int((len(parameterValues) / float(2)) - 0.5)]) config = configuration(conf, self.numOPs) self.configurations.append(config) return self.configurations
def __init__(self): self.config = configuration() self.input_files = self.config.get_input_files() self.algorithms = [] self.metrics = {} self.temporary_directory = './temp/' self.results_file = 'results.sqlite' self.realtime = RealTimeEmulation() self.random_access_records = None self.clean_after_use = True self.check_for_losslelssness = False self.file_info = {} self.results = result_storage.StorageManager() self.options = command_line_parser.Parser() self.init_logging( logging.DEBUG if self.options.verbose() else logging.INFO) # some pandas settings to get printing of the table right pandas.set_option('display.height', 1000) pandas.set_option('display.max_rows', 500) pandas.set_option('display.max_columns', 500) pandas.set_option('display.width', 1000) self._load_algorithms()
def start(self): if self.start_called: raise RunTimeError self.start_called = True # Read parameter file config = configuration.configuration("rc_receiver") connectparams = config.load()['connect'] # Open serial port with parameters s = serial.Serial() s.baudrate = connectparams['baudrate'] s.port = connectparams['port'] s.timeout = connectparams['timeout'] s.open() if s.is_open: self.sp = s i = 0 # Just read some lines line = self.sp.readline() while line and i < 10: line = self.sp.readline() i += 1 super(RCReader, self).start()
def __init__(self): logging.config.fileConfig("logging.ini") self.__logger = logging.getLogger('htmlparser') c = configuration.configuration() c.fileConfig("configuration.ini") self.__RETRY_TIMES__ = int(c.getValue("Runtime", "retry_times")) self.__PAGE_INTERVAL__ = int(c.getValue("Runtime", "page_interval"))
def connect(self): """ Read all configuration parameters (not just connect) and use the connect parameters to create new RoboClaw API handle. """ # First load configuration file config = configuration.configuration("roboclaw") allparams = config.load() self.velocityparams = allparams['velocity'] self.angleparams = allparams['angle'] # Use connect configuration to create a RoboClaw API handle portname = allparams['connect']['port'] if portname == 'TEST': self.roboclaw = Roboclaw_stub() else: baudrate = allparams['connect']['baudrate'] timeout = allparams['connect']['timeout'] retries = allparams['connect']['retries'] newrc = Roboclaw(portname, baudrate, timeout, retries) if newrc.Open(): self.roboclaw = newrc else: raise ValueError("Could not connect to RoboClaw. {} @ {}".format(portname, baudrate))
def screenshots(app_name, img_count): local_image_path = os.path.dirname(os.path.abspath(sys.argv[0])) # get remote path vendor = querydb.get_vendor_name(sys.argv[2]).lower().strip() cfg_file = vendor + '.ini' cfg = configuration.configuration() cfg.fileConfig(os.path.join(local_image_path, 'config', cfg_file)) uid = querydb.get_uid(sys.argv[2]) remote_image_path = cfg.getValue(uid, 'remote_image_path') fname = app_name + str(img_count) + '.png' local_file = os.path.join(local_image_path, uid + fname).replace('\\', '/') remote_file = os.path.join(remote_image_path, fname).replace('\\', '/') # screeshot and upload remote host device = adbtools.AdbTools(uid) device.screenshot(fname, local_file) ip = common_config.getValue('IMAGEHOST', 'ip') username = common_config.getValue('IMAGEHOST', 'username') passwd = common_config.getValue('IMAGEHOST', 'passwd') remote_host = ssh.SSHAction(ip, username, passwd) remote_host.upload_file(local_file, remote_file) remote_host.close() # delete local file delete_file(local_file)
def sincronizar(argv): full_path = os.path.realpath(__file__) #Se averigua la ruta dirname = os.path.dirname(full_path) #se obtiene el directorio config = configuration.configuration(dirname + '/Resources/timantti.conf') options = config.configSection('Database') #se obtienen los valores del archivo de configuracion newDB = DB.databaseHandlerTable(options.get('host'),options.get('user'),options.get('pass'),options.get('db'),options.get('table')) #crea la conexion a la base de datos leyendo los datos desde el archivo de configuracion #newDB = DB.databaseHandlerTable() #crea la conexion a la base de datos y se establece sobre la tabla generic_xml elements = newDB.getItems(); tables = [] for element in elements: if element[4] not in tables: tables.append(element[4]) #saca los elementos unicos (no chequea el campo tags) tables_to_insert = checkExistence(newDB,tables) #Tablas que se deben crear en la base de datos (No estan) #print tables_to_insert if len(tables_to_insert) > 0: for element in tables_to_insert: #print element columns_to_create = newDB.readTags(element) primary = newDB.readTagPrimary(element) print primary DB.databaseHandlerTable.createTableforXML(newDB,element,columns_to_create,primary)
def exec_unit(args=None): if args is None: args = configuration() CONFIGURATIONS_DIR = os.path.join(os.path.dirname(__file__)) folder_name = 'simulation_{}'.format(args.id) path_name = os.path.join(CONFIGURATIONS_DIR, folder_name) if not os.path.exists(path_name): os.mkdir(path_name) param_log_name = os.path.join(path_name, args.name + '_param.log') if os.path.exists(param_log_name): raise Exception('Log file already exists') args.client = {'clientname': socket.gethostname()} FORMAT = '%(asctime)-15s %(clientname)s %(message)s' log_name = os.path.join(path_name, args.name) + '.log' logging.basicConfig(filename=log_name, level=logging.INFO, format=FORMAT, datefmt='%m/%d/%Y %I:%M:%S %p') configuration_str = '' for arg in vars(args): configuration_str = configuration_str + arg + ' ' + str( getattr(args, arg)) + '\n' print(configuration_str) logging.info(configuration_str, extra=args.client) stats_train, stats_test = train.main(args) # stats_train, stats_test = evaluate.main(args) args.client = args.client['clientname'] if logging.root: del logging.root.handlers[:] with open(folder_name + '/' + args.name, 'wb') as pickle_out: pickle.dump((stats_test, stats_train), pickle_out) with open(param_log_name, 'w') as log_file: log_file.write(json.dumps(vars(args))) return stats_test.get_scores()
def ensureready(self): """ Makes sure this chassis class is ready for work by ensuring the required information is loaded and ready. """ if len(self.wheels) > 0: return # Initialize motor controller dictionary. self.init_motorcontrollers() # Load configuration from JSON. config = configuration.configuration("roverchassis") wheeljson = config.load() # Using the data in configuration JSON file, create a wheel object. for wheel in wheeljson: # Retrieve name and verify uniqueness. name = wheel['name'] if name in self.wheels: raise ValueError("Duplicate wheel name {} encountered.".format(name)) # Initialize all optional motor control values to None steeringcontrol = None steeringparam = None rollingcontrol = None rollingparam = None # Fill in any rolling velocity motor control and associated parameters rolling = wheel['rolling'] if rolling: rollingtype = rolling[0] if len(rolling) == 2: rollingparam = rolling[1] else: rollingparam = rolling[1:] if rollingtype in self.motorcontrollers: rollingcontrol = self.motorcontrollers[rollingtype] else: raise ValueError("Unknown motor control type") # Fill in any steering angle motor control and associated parameters steering = wheel['steering'] if steering: steeringtype = steering[0] if len(steering) == 2: steeringparam = steering[1] else: steeringparam = steering[1:] if steeringtype in self.motorcontrollers: steeringcontrol = self.motorcontrollers[steeringtype] else: raise ValueError("Unknown motor control type") # Add the newly created roverwheel object to wheels dictionary. self.wheels[name] = roverwheel(name, wheel['x'], wheel['y'], rollingcontrol, rollingparam, steeringcontrol, steeringparam) # Wheels are initialized, set everything to zero. self.move_velocity_radius(0)
def synFeed(savedb,feed,saveas):# funcion de sincronizacion de feeds full_path = os.path.realpath(__file__) #Se averigua la ruta a manager.py filehandler = FH.XMLfileHandler() dirname = os.path.dirname(full_path) #se obtiene el directorio ####Carga de la configuracion#### config = configuration.configuration(dirname + '/Resources/timantti.conf') options = config.configSection('Database') #se obtienen los valores del archivo de configuracion managementDB = DB.databaseHandlerTable(options.get('host'),options.get('user'),options.get('pass'),options.get('db'),options.get('table')) #crea la conexion a la base de datos leyendo los datos desde el archivo de configuracion managementDB.updateStatistics(savedb) #managementDB = DB.databaseHandlerTable() #managementDB.insertCron(savedb) #no es necesario insertar cron aca try: feed_downloader = FD.feeddownloader() feed_downloader.downloadfeed(feed,saveas) except: writeLog(dirname + '/Resources/events.log','Error en la descarga de ' + str(feed)) ##Solucionar el problema del directorio relativo para los crones exit if os.system('python ' + dirname + '/setup_newDB.py ' + dirname + '/Resources/generic-handler.xml') !=0: log = open(dirname + '/Resources/events.log','python ' + dirname + '/setup_newDB.py ' + dirname + '/Resources/generic-handler.xml failed to update generic-handler file') if os.system('python ' + dirname + '/synchronize_generic.py') !=0: #Sincronizamos las tablas con el archivo generic-handler.xml writeLog(dirname + '/Resources/events.log','python ' + dirname + '/synchronize_generic.py' + ' fail to sync generic feed') if os.system('python ' + dirname + '/synchronize_xml.py ' + str(savedb) ) !=0: #sincronizamos la tabla nueva writeLog(dirname + '/Resources/events.log','python ' + dirname + '/synchronize_xml.py ' + str(savedb) + ' failed to sync feed') ##corregir el error porque sino siempre da error cuando hay entradas duplicadas
def __init__(self, configuration=None, name=None, globals=None, locals=None, parent=None, title=None): """ configuration: object of type "configuration" from "configuration.py" name: name of configuration, e.g. "alio_diffractometer_saved_positions", "timing_modes" globals: When using "name=...", dictionary containing available motor objects. e.g. "from instrumentation import *" populates the global names space, globals=globals() to make these available inside the SavedPositionsPanel title: overrides user-configurable title (for backward compatibility) """ self.cache = {} self.locals = locals self.globals = globals if name is not None: self.name = name if configuration is not None: self.configuration = configuration if self.configuration is None and self.name is None: raise RuntimeError( "SavedPositionsPanel requires 'configuration' or 'name'") if self.configuration is None: from configuration import configuration self.configuration = configuration(self.name, globals=globals, locals=locals) if title is not None: self.configuration.title = title wx.Frame.__init__(self, parent=parent) # Icon from Icon import SetIcon SetIcon(self, self.icon, self.configuration.name) self.layout() self.Fit() self.Show() # Make sure "on_input" is called only after "update_settings". # Call the "on_input" routine whenever the user presses Enter. self.Bind(wx.EVT_TEXT_ENTER, self.on_input) # Periodically update the displayed fields. self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnTimer) self.timer.Start(5000, oneShot=True) from threading import Thread self.update_thread = Thread(target=self.keep_updated) self.update_thread.daemon = True self.update_thread.start()
def __init__(self, settings = None): if not settings: settings = configuration() self.settings = settings self.fetchpath = "/api?apikey=" + self.settings.apikey + "&mode=" self.servername = self.settings.host + ":" + self.settings.port self.output = "&output=json"
def GH(r): return { 'LISTED_LOCALES': [l.split(',') for l in configuration('listed_langs').split('\n')], 'unread_count': Message.message_count(r), }
def delFeed( savedb, deletedb): #Borra el cron de la base de datos y lo elimina del sistema full_path = os.path.realpath(__file__) #Se averigua la ruta a manager.py dirname = os.path.dirname(full_path) #se obtiene el directorio ####Carga de la configuracion#### config = configuration.configuration(dirname + '/Resources/timantti.conf') options = config.configSection( 'Database') #se obtienen los valores del archivo de configuracion managementDB = DB.databaseHandlerTable( options.get('host'), options.get('user'), options.get('pass'), options.get('db'), options.get('table') ) #crea la conexion a la base de datos leyendo los datos desde el archivo de configuracion managementDB.deleteStatistics(savedb) #managementDB = DB.databaseHandlerTable() cron_id = managementDB.getCronID(savedb) filehandler = FH.XMLfileHandler() saveas_field = managementDB.readSaveas( savedb) #Se obtiene el campo saveas para eliminar el archivo xml deletecronFile( cron_id) ##Borra la entrada correspondiente del archivo de cron managementDB.deleteCron( savedb) ##Elimina la entrada de la tabla cron_management try: feed_downloader = FD.feeddownloader() feed_downloader.removefeed(str(saveas_field[0][0])) except: writeLog(dirname + '/Resources/events.log', 'Error en el borrado de ' + str(saveas_field[0][0])) exit filehandler.deletefromGenericXML( savedb) #se borra la entrada del archivo generic-handler.xml save_name = managementDB.readName(savedb) print "save_name:" + ' ' + save_name[0][0] if deletedb == 'y': #Si el usuario lo indica, borramos tambien la base de datos del feed, caso contrario queda a su disposicion managementDB.dropTableFeed(savedb) managementDB.deleteDescription(savedb) else: managementDB.insertOldFeed(save_name[0][0], savedb) if os.system('python ' + dirname + '/setup_newDB.py ' + dirname + '/Resources/generic-handler.xml') != 0: log = open('Resources/events.log', 'a+') log.write( 'python ' + dirname + '/setup_newDB.py ' + dirname + '/Resources/generic-handler.xml failed to update generic-handler file\n' ) log.close()
def __parseNode(node): #print 'node.text', node.text #print 'node.tag', node.tag nodeObject = configuration(node.attrib, node.tag, node.text) for child in node: nodeObject.children.append(configReader.__parseNode(child)) return nodeObject
def addFeed(savedb,mins,hours,dayofmonth,month,dayofweek,name,url,feed,saveas,root,primary_id,tag): #agrega un cron a la base de datos y lo crea en el sistema filehandler = FH.XMLfileHandler() full_path = os.path.realpath(__file__) #Se averigua la ruta a manager.py dirname = os.path.dirname(full_path) #se obtiene el directorio ####Carga de la configuracion#### config = configuration.configuration(dirname + '/Resources/timantti.conf') options = config.configSection('Database') #se obtienen los valores del archivo de configuracion managementDB = DB.databaseHandlerTable(options.get('host'),options.get('user'),options.get('pass'),options.get('db'),options.get('table')) #crea la conexion a la base de datos leyendo los datos desde el archivo de configuracion #managementDB = DB.databaseHandlerTable() managementDB.insertCron(savedb) #inserta el cron en la base de datos managementDB.insertStatisticsFirstTime(savedb) hours = '*' if hours=='0' else hours if (mins =='0' and hours == '*'): mins = '*' dayofmonth = '*' if dayofmonth=='0' else dayofmonth month = '*' if month=='0' else month dayofweek = '*' if dayofweek=='0' else dayofweek try: feed_downloader = FD.feeddownloader() feed_downloader.downloadfeed(feed,saveas) except: writeLog(dirname + '/Resources/events.log','Error en la descarga de ' + str(feed)) exit filehandler.writeGenericXML(name,url,feed,saveas,savedb,root,primary_id,tag) #Agrega las entradas del feed a generic-handler.xml if os.system('python ' + dirname + '/setup_newDB.py ' + dirname + '/Resources/generic-handler.xml') !=0: #anda siempre porque ./setup_newDB usa por default generic-handler.xml log = open('Resources/events.log','python ' + dirname + '/setup_newDB.py ' + dirname + '/Resources/generic-handler.xml failed to update generic-handler file') if os.system('python ' + dirname + '/synchronize_generic.py') !=0: #Sincronizamos las tablas con el archivo generic-handler.xml writeLog('Resources/events.log','python ' + dirname + '/synchronize_generic.py' + ' fail to sync generic feed') if os.system('python ' + dirname + '/synchronize_xml.py ' + str(savedb) ) !=0: #sincronizamos la tabla nueva writeLog('Resources/events.log','python ' + dirname + '/synchronize_xml.py ' + str(savedb) + ' failed to sync feed') ##########################Crea el cron correspondiente. Habilitar cuando este la parte grafica terminada######################################################## cron_id = managementDB.getCronID(savedb) output = open(dirname + '/Resources/cron_feeds','a+') output.write("#cron_id: " + str(cron_id) + '\n') output.write(str(mins) + ' ' + str(hours) + ' ' + str(dayofmonth) + ' ' + str(month) + ' ' + str(dayofweek) + ' python ' + dirname + '/manager.py syn ' + str(savedb) + ' ' + str(feed) + ' ' + str(saveas) + ' \n') output.close()
def initApplicationCore(self, config, sabApi, window): if not sabApi: sabApi = api() self.api = sabApi if not window: window = cursesWindow() self.window = window if not config: config = configuration.configuration() self.config = config
def main(): if len(sys.argv) < 2: sys.exit('Usage: %s xml archive' % sys.argv[0] + '\n') full_path = os.path.realpath(__file__) #Se averigua la ruta dirname = os.path.dirname(full_path) #se obtiene el directorio ####Carga de la configuracion#### config = configuration.configuration(dirname + '/Resources/timantti.conf') options = config.configSection('Database') #se obtienen los valores del archivo de configuracion newDB = DB.databaseHandlerTable(options.get('host'),options.get('user'),options.get('pass'),options.get('db'),options.get('table')) #crea la conexion a la base de datos leyendo los datos desde el archivo de configuracion handler = XGH.xmlGenericHandler(sys.argv[1]) #inicializa el handler de la base de datos newDB.dropTable()#borra la tabla newDB.createTable()#crea nuevamente la tabla tags = ("name","url","feed","saveas","savedb","root","primary_id","tag") #arma los tags para insertar en la tabla generica values = handler.getBody('site',tags) #obtiene los datos del XML generico if len(values)!=1: #En caso de que generic-handler.xml este vacio finish = False x = len(tags) - 1 i = 0 z = len(tags) while not finish: valor_bd = '(' + "'" + "','".join(values[i:z]) + "'" + ')' #arma la cadena para insertar los valores y el primer campo <tag> #print valor_bd newDB.insertItem(tags,valor_bd) #inserta en la tabla hasta el primer <tag> x += 1 if len(values) > len(tags): #comprueba si hay mas de un tag while ((values[x] <> 'finarbol')): #quedan mas tags values_add = "','".join(values[i:z - 1]) valor_bd = '(' + "'" + (values_add) + "','" + values[x] + "'" + ')' #print valor_bd,'\n' newDB.insertItem(tags,valor_bd) #inserta en la tabla el otro <tag> x+=1 if (values[x + 1] == 'finito'): finish = True else: i = x + 1 z = i + len(tags) x = z - 1 else: finish = True
def __init__(self): logging.config.fileConfig("logging.ini") self.__logger = logging.getLogger('grab') self.__c = configuration.configuration() self.__c.fileConfig("configuration.ini") self.__RETRY_TIMES__ = int(self.__c.getValue("Runtime", "retry_times")) self.__f = formpage.formpage() self.__h = htmlparser.htmlpaser() self.__j = jsonpost.jsonpost() self.__js = jspost.jspost() self.__taskID = ""
def __init__(self, settings = None): if not settings: settings = configuration() self.settings = settings self.postdata = None self.header = { 'User-Agent' : 'SabnzbdAutomation' } if self.settings.username and self.settings.password: self.postdata = 'ma_password='******'&' +\ 'ma_username='******'Content-type'] = 'application/x-www-form-urlencoded'
def anasayfa(request): # sayfa = Sayfa.al_anasayfa() # lang = request.LANGUAGE_CODE searchForm = SearchForm() slides = [Vitrin.get_slides(), Vitrin.get_slides(type=1), Vitrin.get_slides(type=2)] context = {'slides': slides, 'minislides':MiniVitrin.get_slides(request.LANGUAGE_CODE), 'srForm':searchForm, 'nasil_slide_zaman': configuration('nasil_slide_zaman') or '0', } return render_to_response('index.html', context, context_instance=RequestContext(request))
def instantiate_entity(self, e, soap_client): """Instantiate an appropriate python class given an entity returned from a SOAP call. :param e: SOAP entity. :param soap_client: BAM SOAP client connection for the entity instance to use when accessing the API. :return: A type specific instance object of the SOAP entity or generic entity object. None if there is no type. """ if 'type' in e: t = e['type'] if t == entity.Configuration: return configuration(self, e, soap_client) elif t == entity.User: return user(self, e, soap_client) elif t == entity.Zone: return zone(self, e, soap_client) elif t == entity.View: return view(self, e, soap_client) elif t == entity.IP4Block: return ip4_block(self, e, soap_client) elif t == entity.IP4Network: return ip4_network(self, e, soap_client) elif t == entity.HostRecord: return host_record(self, e, soap_client) elif t == entity.AliasRecord: return alias_record(self, e, soap_client) elif t == entity.MXRecord: return mx_record(self, e, soap_client) elif t == entity.TXTRecord: return text_record(self, e, soap_client) elif t == entity.HINFORecord: return host_info_record(self, e, soap_client) elif t == entity.SRVRecord: return srv_record(self, e, soap_client) elif t == entity.NAPTRRecord: return naptr_record(self, e, soap_client) elif t == entity.ExternalHostRecord: return external_host_record(self, e, soap_client) elif t == entity.GenericRecord: return generic_record(self, e, soap_client) elif t == entity.EnumZone: return enum_zone(self, e, soap_client) elif t == entity.EnumNumber: return enum_number(self, e, soap_client) elif t in deployment_role.roles: return deployment_role(self, e, soap_client) elif t == entity.IP4Address: return ip4_address(self, e, soap_client) elif t == entity.Server: return server(self, e, soap_client) else: return entity(self, e, soap_client) else: return None
def addDesc(savedb,description): #Agrega la descripcion en la tabla description full_path = os.path.realpath(__file__) #Se averigua la ruta a manager.py dirname = os.path.dirname(full_path) #se obtiene el directorio ####Carga de la configuracion#### config = configuration.configuration(dirname + '/Resources/timantti.conf') options = config.configSection('Database') #se obtienen los valores del archivo de configuracion managementDB = DB.databaseHandlerTable(options.get('host'),options.get('user'),options.get('pass'),options.get('db'),options.get('table')) #crea la conexion a la base de datos leyendo los datos desde el archivo de configuracion #managementDB = DB.databaseHandlerTable() managementDB.insertDescription(savedb,description)
def synFeed(savedb, feed, saveas): # funcion de sincronizacion de feeds full_path = os.path.realpath(__file__) #Se averigua la ruta a manager.py filehandler = FH.XMLfileHandler() dirname = os.path.dirname(full_path) #se obtiene el directorio ####Carga de la configuracion#### config = configuration.configuration(dirname + '/Resources/timantti.conf') options = config.configSection( 'Database') #se obtienen los valores del archivo de configuracion managementDB = DB.databaseHandlerTable( options.get('host'), options.get('user'), options.get('pass'), options.get('db'), options.get('table') ) #crea la conexion a la base de datos leyendo los datos desde el archivo de configuracion managementDB.updateStatistics(savedb) #managementDB = DB.databaseHandlerTable() #managementDB.insertCron(savedb) #no es necesario insertar cron aca try: feed_downloader = FD.feeddownloader() feed_downloader.downloadfeed(feed, saveas) except: writeLog( dirname + '/Resources/events.log', 'Error en la descarga de ' + str(feed) ) ##Solucionar el problema del directorio relativo para los crones exit if os.system('python ' + dirname + '/setup_newDB.py ' + dirname + '/Resources/generic-handler.xml') != 0: log = open( dirname + '/Resources/events.log', 'python ' + dirname + '/setup_newDB.py ' + dirname + '/Resources/generic-handler.xml failed to update generic-handler file' ) if os.system( 'python ' + dirname + '/synchronize_generic.py' ) != 0: #Sincronizamos las tablas con el archivo generic-handler.xml writeLog( dirname + '/Resources/events.log', 'python ' + dirname + '/synchronize_generic.py' + ' fail to sync generic feed') if os.system('python ' + dirname + '/synchronize_xml.py ' + str(savedb)) != 0: #sincronizamos la tabla nueva writeLog( dirname + '/Resources/events.log', 'python ' + dirname + '/synchronize_xml.py ' + str(savedb) + ' failed to sync feed' ) ##corregir el error porque sino siempre da error cuando hay entradas duplicadas
def __init__(self): #self.__pageinfo = "" # Browser self.__br = mechanize.Browser() self.__br_i = mechanize.Browser() #self.__br = mechanize.urlopen("https://taobao.com") # Cookie Jar cj = cookielib.LWPCookieJar() self.__br.set_cookiejar(cj) self.__br_i.set_cookiejar(cj) # Browser options self.__br.set_handle_equiv(True) self.__br.set_handle_gzip(True) self.__br.set_handle_redirect(True) self.__br.set_handle_referer(True) self.__br.set_handle_robots(False) # Browser options self.__br_i.set_handle_equiv(True) self.__br_i.set_handle_gzip(True) self.__br_i.set_handle_redirect(True) self.__br_i.set_handle_referer(True) self.__br_i.set_handle_robots(False) # Follows refresh 0 but not hangs on refresh > 0 self.__br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) # Follows refresh 0 but not hangs on refresh > 0 self.__br_i.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) # Want debugging messages? #br.set_debug_http(True) #br.set_debug_redirects(True) #br.set_debug_responses(True) # User-Agent (this is cheating, ok?) self.__br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')] self.__br_i.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')] logging.config.fileConfig("logging.ini") self.__logger = logging.getLogger('formpage') c = configuration.configuration() c.fileConfig("configuration.ini") self.__RETRY_TIMES__ = int(c.getValue("Runtime","retry_times")) self.__PAGE_INTERVAL__ = int(c.getValue("Runtime","page_interval")) self.__h = htmlparser.htmlpaser()
class avroutility: config = configuration() logger = logging.getLogger("bespoke") handler = RotatingFileHandler("bespoke.log", mode="a", maxBytes=500000, backupCount=5) ''' Pass the type of domain you would like to load ''' def loadschema(self, domain): if not self.logger.handlers: self.logger.addHandler(self.handler) self.logger.setLevel(self.config.loglevel) self.logger.info( "Started loadschema call for domain - {}".format(domain)) if not type(domain) == domainschema: raise ValueError( "Invalid domain schema sent, use domainschema Enum from the module to set this." ) parsedoutput = "" try: schemaname = "" schemastring = "" if domain.value == domainschema.PRODUCT.value: schemaname = self.config.productschemaname elif domain.value == domainschema.CUSTOMER.value: schemaname = self.config.customerschemaname elif domain.value == domainschema.ORDER.value: schemaname = self.config.orderschemaname schemafile = os.path.join(os.path.dirname(__file__), schemaname) self.logger.info("Schema {} to load from {}".format( schemaname, schemafile)) with open(schemafile, 'r') as f: '''key is to parse and check if its valid''' parsedoutput = schema.Parse(f.read()) f.close() self.logger.info("Schema load complete") except Exception as ex: self.logger.exception(ex) finally: self.logger.info( "Completed loadschema call for domain - {}".format(domain)) return parsedoutput
def buildConfigurations(self): lhd = lhs(len(self.paramsValues), samples=self.numSamples) for indexLHD, itemLHD in enumerate(lhd): conf = [] for indexRow, itemRow in enumerate(itemLHD): parameterValues = self.paramsValues[indexRow] conf.append( parameterValues[int(len(parameterValues) * itemRow - 0.5)]) config = configuration(conf, self.numOPs) self.configurations.append(config) return self.configurations
def main(): args = configuration() base_name = args.name for idx in range(1, 4): # args.id = 1000 args.sim_num = idx * 10 # args.batch_size = 128 # args.workers_num = 1 # args.epochs = 200 args.name = base_name + '_{}'.format(args.sim_num) # args.gbn = 0 # args.notes = 'baseline' min_error, mean_error = exec_unit(args) message = 'Simulation Number {0} Completed\nMin Error - {1:.3f}\nMean Error - {2:.3f}'.format( args.sim_num, min_error, mean_error) send_notification(message, vars(args))
def addDesc(savedb, description): #Agrega la descripcion en la tabla description full_path = os.path.realpath(__file__) #Se averigua la ruta a manager.py dirname = os.path.dirname(full_path) #se obtiene el directorio ####Carga de la configuracion#### config = configuration.configuration(dirname + '/Resources/timantti.conf') options = config.configSection( 'Database') #se obtienen los valores del archivo de configuracion managementDB = DB.databaseHandlerTable( options.get('host'), options.get('user'), options.get('pass'), options.get('db'), options.get('table') ) #crea la conexion a la base de datos leyendo los datos desde el archivo de configuracion #managementDB = DB.databaseHandlerTable() managementDB.insertDescription(savedb, description)
def get_configurations(self, max_results=100): """Get up to max_results configurations. :param max_results: Maximum number of configurations to be returned. :return: List of :py:mod:`configuration` objects. """ try: soap_entities = self._soap_client.service.getEntities( 0, entity.Configuration, 0, max_results) if has_response(soap_entities): return [ configuration(self, e, self._soap_client) for e in soap_entities.item ] else: return [] except WebFault as e: raise api_exception(e.message)
def connect(self): """ Read serial port connection parameters from JSON configuration file and open the port. """ # Read parameter file config = configuration.configuration("dmfe") connectparams = config.load()['connect'] # Open serial port with parameters s = serial.Serial() s.baudrate = connectparams['baudrate'] s.port = connectparams['port'] s.timeout = connectparams['timeout'] s.open() if s.is_open: self.sp = s
def get_configuration(self, name): """Get a named configuration. :param name: Name of the BAM configuration. :return: :py:mod:`configuration` object of the named configuration """ try: soap_entities = self._soap_client.service.getEntitiesByName( 0, name, entity.Configuration, 0, 10) except WebFault as e: raise api_exception(e.message) if not hasattr(soap_entities, 'item') or len(soap_entities.item) == 0: raise api_exception('No configuration named %s found' % name) elif len(soap_entities.item) == 1: return configuration(self, soap_entities.item[0], self._soap_client) else: raise api_exception('More than 1 configuration called %s found' % name)
def delFeed(savedb,deletedb): #Borra el cron de la base de datos y lo elimina del sistema full_path = os.path.realpath(__file__) #Se averigua la ruta a manager.py dirname = os.path.dirname(full_path) #se obtiene el directorio ####Carga de la configuracion#### config = configuration.configuration(dirname + '/Resources/timantti.conf') options = config.configSection('Database') #se obtienen los valores del archivo de configuracion managementDB = DB.databaseHandlerTable(options.get('host'),options.get('user'),options.get('pass'),options.get('db'),options.get('table')) #crea la conexion a la base de datos leyendo los datos desde el archivo de configuracion managementDB.deleteStatistics(savedb) #managementDB = DB.databaseHandlerTable() cron_id = managementDB.getCronID(savedb) filehandler = FH.XMLfileHandler() saveas_field = managementDB.readSaveas(savedb) #Se obtiene el campo saveas para eliminar el archivo xml deletecronFile(cron_id) ##Borra la entrada correspondiente del archivo de cron managementDB.deleteCron(savedb)##Elimina la entrada de la tabla cron_management try: feed_downloader = FD.feeddownloader() feed_downloader.removefeed(str(saveas_field[0][0])) except: writeLog(dirname + '/Resources/events.log','Error en el borrado de ' + str(saveas_field[0][0])) exit filehandler.deletefromGenericXML(savedb) #se borra la entrada del archivo generic-handler.xml save_name = managementDB.readName(savedb) print "save_name:" + ' ' + save_name[0][0] if deletedb == 'y': #Si el usuario lo indica, borramos tambien la base de datos del feed, caso contrario queda a su disposicion managementDB.dropTableFeed(savedb) managementDB.deleteDescription(savedb) else: managementDB.insertOldFeed(save_name[0][0],savedb) if os.system('python ' + dirname + '/setup_newDB.py ' + dirname + '/Resources/generic-handler.xml') !=0: log = open('Resources/events.log','a+') log.write('python ' + dirname + '/setup_newDB.py ' + dirname + '/Resources/generic-handler.xml failed to update generic-handler file\n') log.close()
def main(): args = configuration() base_name = args.name base_id = args.id for idx in range(1, 6): args.id = base_id + idx - 1 seed_val = random.randrange(10000000) seed_system(seed_val) args.seed = seed_val args.name = base_name + '_{}'.format(args.id) time = str(datetime.now()) scores = exec_unit(args) graph_path = create_graphs(sim_num=args.id, linear=True) message = '{0}\nSimulation Number {1} Completed\n' \ 'Min Error - {2:.3f}\n' \ 'Mean Error - {3:.3f}\n' \ 'Val Error - {4:.3f}'.format(time, args.id, scores[0], scores[1], scores[2]) send_notification(message, vars(args), graph_path, args)
def exec_unit(args=None): if args is None: args = configuration() CONFIGURATIONS_DIR = os.path.join(os.path.dirname(__file__)) folder_name = 'simulation_{}'.format(args.id) path_name = os.path.join(CONFIGURATIONS_DIR, folder_name) if not os.path.exists(path_name): os.mkdir(path_name) log_name = os.path.join(path_name, args.name + '.log') if os.path.exists(log_name): raise Exception('Log file already exists') stats_train, stats_test = train.main(args) with open(folder_name + '/' + args.name, 'wb') as pickle_out: pickle.dump((stats_test, stats_train), pickle_out) with open(log_name, 'w') as log_file: log_file.write(json.dumps(vars(args))) return stats_test.get_scores()
def __init__(self): funcName = "[common.NewzWorthyApp.__init__]" self.loglevel = int(Prefs['NWLogLevel']) Thread.Create(log_level_watcher) log(5, funcName, 'importing downloader') from downloader import Downloader log(5, funcName, 'importing Queue') from queue import Queue from unpacker import Unpacker, UnpackerManager from nntpclient import nntpManager from updater import Updater from migrator import Migrator from configuration import configuration from updates import updates import nzbmatrix import newzbin import nzbindexnl try: self.num_client_threads = int( Dict[nntpSettingDict]['TotalConnections']) except: self.num_client_threads = 1 log(4, funcName, 'Initializing Queue') self.queue = Queue(self) log(4, funcName, 'Initializing Downloader') self.cfg = configuration(self) self.nntpManager = nntpManager(self) self.recoverer = None self.stream_initiator = None self.updater = Updater() self.migrator = Migrator(self) self.downloader = Downloader(self) self.unpacker_manager = UnpackerManager(self) self.updates = updates() # self.tv_nzb_provider = None # self.movie_nzb_provider = None # self.tv_nzb_provder_logged_in = False # self.movie_nzb_provider_logged_in = False self.nzb = None self.loggedInNZBService = False
def buildConfigurations(self): pbd = pbdesign(len(self.paramsValues)) for indexPBD, itemPBD in enumerate(pbd): conf = [] for indexRow, itemRow in enumerate(itemPBD): parameterValues = self.paramsValues[indexRow] # value == 1 --> MAXValue of the corresponding parameter if itemRow == 1: conf.append(parameterValues[-1]) # value == -1 --> minValue of the corresponding parameter elif itemRow == -1: conf.append(parameterValues[0]) config = configuration(conf, self.numOPs) self.configurations.append(config) return self.configurations
def __init__(self): funcName = "[common.NewzWorthyApp.__init__]" self.loglevel = int(Prefs['NWLogLevel']) Thread.Create(log_level_watcher) log(5, funcName, 'importing downloader') from downloader import Downloader log(5, funcName, 'importing Queue') from queue import Queue from unpacker import Unpacker, UnpackerManager from nntpclient import nntpManager from updater import Updater from migrator import Migrator from configuration import configuration from updates import updates import nzbmatrix import newzbin import nzbindexnl try: self.num_client_threads = int(Dict[nntpSettingDict]['TotalConnections']) except: self.num_client_threads = 1 log(4, funcName, 'Initializing Queue') self.queue = Queue(self) log(4, funcName, 'Initializing Downloader') self.cfg = configuration(self) self.nntpManager = nntpManager(self) self.recoverer = None self.stream_initiator = None self.updater = Updater() self.migrator = Migrator(self) self.downloader = Downloader(self) self.unpacker_manager = UnpackerManager(self) self.updates = updates() # self.tv_nzb_provider = None # self.movie_nzb_provider = None # self.tv_nzb_provder_logged_in = False # self.movie_nzb_provider_logged_in = False self.nzb = None self.loggedInNZBService = False
def register(self, request, **kwargs): """ Given a username, email address and password, register a new user account, which will initially be inactive. Along with the new ``User`` object, a new ``registration.models.RegistrationProfile`` will be created, tied to that ``User``, containing the activation key which will be used for this account. An email will be sent to the supplied email address; this email should contain an activation link. The email will be rendered using two templates. See the documentation for ``RegistrationProfile.send_activation_email()`` for information about these templates and the contexts provided to them. After the ``User`` and ``RegistrationProfile`` are created and the activation email is sent, the signal ``registration.signals.user_registered`` will be sent, with the new ``User`` as the keyword argument ``user`` and the class of this backend as the sender. """ username, email, password = kwargs['username'], kwargs['email'], kwargs['password1'] if Site._meta.installed: site = Site.objects.get_current() else: site = RequestSite(request) create_active = not configuration('email_activation') or hasattr(request,'via_facebook') fnc = getattr(RegistrationProfile.objects, 'create_active_user' if create_active else 'create_inactive_user') new_user = fnc(username, email, password, site) signals.user_registered.send(sender=self.__class__, user=new_user, request=request) return new_user
def showPlace(request, id): try: place = Place.objects.get(pk=id,active=True) except Place.DoesNotExist: raise Http404 # owner = place.owner # profile = owner.profile properties=[ (_(u'Place type'),place.get_type_display()), (_(u'Space offered'),place.get_space_display()), (_(u'Accommodates'),place.capacity), (_(u'Size'), place.get_size() ), (_(u'Bedrooms'),place.bedroom), (_(u'Bed type'),place.get_bed_type_display()), (_(u'Bathrooms'),place.bathrooms), (_(u'Cancellation'),place.get_cancellation_display()), ] # if place.cleaning_fee: # properties.append((_(u'Cleaning Fee'),place.cleaning_fee)) context = {'place':place, 'bform':BookingForm(place.max_stay), 'properties':properties , # 'profile':profile, 'service_fee':configuration('guest_fee'), 'amens':place.getTags(request.LANGUAGE_CODE), 'translations':place.get_translation_list(), # 'other_places':Place.objects.filter(active=True, published=True, owner=profile.user).exclude(pk=place.id), 'meta_keywords':place.title, 'meta_desc':place.description, 'page_title':place.title, } if request.LANGUAGE_CODE in place.get_translation_list(): trns = place.get_translation(request.LANGUAGE_CODE) context['description'], context['title'] = trns context['meta_desc'] = trns[0] context['page_title'] = context['meta_keywords'] = trns[1] return render_to_response('show_place.html', context, context_instance=RequestContext(request))
def testPlanePointcloud(): import processor import configuration cfg = configuration.configuration(TEST_FOLDER) #sc = scanner.scanner(cfg) pc = processor.processor(cfg) #pc.load_data('2009Oct30_162400') pc.load_data('2009Nov04_141226') pc.process_raw_data() debug = False model = PlaneLeastSquaresModel(debug) data = np.asarray(pc.pts3d_bound).T # run RANSAC algorithm ransac_fit, ransac_data = ransac(data,model, 3, 1000, 0.02, 300, # misc. parameters debug=debug,return_all=True) print ransac_fit print ransac_data print 'len inlier',len(ransac_data['inliers']),'shape pts',np.shape(pc.pts3d_bound) pc.pts3d_bound = pc.pts3d_bound[:,ransac_data['inliers']] pc.display_3d('height')
def addPlace(request, ajax=False, id=None): template_name = "add_place_wizard.html" if ajax else "add_place.html" sayfa = Sayfa.al_anasayfa() lang = request.LANGUAGE_CODE user = request.user response = {} new_place = None loged_in = user.is_authenticated() photos = [] profile = user.get_profile() ask_phone = not bool(profile.phone.strip()) if profile.phone else True if id: old_place = get_object_or_404(Place, pk=id) photos = list(old_place.photo_set.values_list('id',flat=True)) if old_place.owner != request.user: return HttpResponseForbidden() old_place.invalidate_caches() else: old_place = Place() if request.method == 'POST': register_form = RegisterForm(request.POST) login_form = LoginForm(request.POST) form = addPlaceForm(request.POST, instance=old_place, req_phone=ask_phone) if form.is_valid(): new_place=form.save(commit=False) new_place.translation_check() # if register_form.is_valid() or loged_in: # if not loged_in: # user = register_form.save(commit=False) # user.username = user.email # user.set_password(register_form.cleaned_data['pass1']) # user.save() phone = form.cleaned_data.get('phone') if phone: profile.phone = phone profile.save() new_place.owner = user new_place.lat = str(new_place.lat) new_place.lon = str(new_place.lon) new_place.lang = request.LANGUAGE_CODE # log.info('%s %s '% (new_place.lang, request.LANGUAGE_CODE)) new_place.save() form.save_m2m() for tag in form.cleaned_data['tags']: new_place.tags.add(tag) # log.info(form.cleaned_data['tags']) new_place.save() d, new = Description.objects.get_or_create(place=new_place, lang=new_place.lang) d.text = new_place.description d.title = new_place.title d.save() tmp_photos = request.session.get('tmp_photos') if tmp_photos: Photo.objects.filter(id__in=tmp_photos).update(place=new_place) if tmp_photos[0]: p=Photo.objects.filter(pk=tmp_photos[0]) if p: p[0].save() request.session['tmp_photos']=[] if not ajax: if not new_place.published: messages.success(request, _('Your place succesfully saved but not published yet.')) messages.info(request, _('You can publish this place by pressing the "Publish" button below.')) else: messages.success(request, _('Your changes succesfully saved.')) return HttpResponseRedirect('%s#do_listPlaces,this'%reverse('dashboard')) else: for e in form.errors: messages.error(request, e) if ajax: response = { 'user':getattr(user,'username'), 'loged_in':loged_in, # 'new_place':repr(new_place), 'errors':form.errors, 'new_place_id':getattr(new_place,'id',0), } return HttpResponse(json.dumps(response), mimetype='application/json') else: form = addPlaceForm(instance=old_place, req_phone=ask_phone) register_form = RegisterForm() login_form = LoginForm() str_fee = _('%s Service Fee '% configuration('host_fee')) context = {'form':form, 'rform':register_form,'lform':login_form,'place':old_place, 'host_fee':configuration('host_fee'), 'str_fee':str_fee, 'photos':photos, 'tags':TagTranslation.objects.filter(lang=request.LANGUAGE_CODE), 'existing_tags':[], } if id: context['existing_tags'] = old_place.tags.values_list('id',flat=True) return render_to_response(template_name, context, context_instance=RequestContext(request))
return table_surface, list_of_edges def show_image(window_name, img, wait=False): hg.cvStartWindowThread() RESIZABLE = 0 hg.cvNamedWindow(window_name, RESIZABLE) hg.cvShowImage(window_name, img) if wait: print 'show_image: press any key to continue..' cv.highgui.cvWaitKey() #------------------------------------ ###CHANGE THIS TO THE DIRECTORY WITH RESULTS FROM CODY: ### change 'codyRobot' to 'dummyScanner' or code tries to find camera drivers, etc. cfg = configuration.configuration(DATA_LOCATION, ROBOT) #'dummyScanner' pc = processor.processor(cfg) pc.features_k_nearest_neighbors = None # Name of dataset will allow loading of saved image / scan. pc.scan_dataset = create_default_scan_dataset( DATASET_ID, z_above_floor)#1.32 ''' PC.LOAD_RAW_DATA() Browses for content with the following names: data/UNIQUE_ID_image.png data/UNIQUE_ID_laserscans.pkl self.image_angle is set or zeroed Sets in pc as: self.img, self.laserscans, sets (or zeros) self.image_angle
def __init__(self, path, parent=None): self.init_in_progress = True self.path = path # load configs for taking scans, etc: self.config = configuration.configuration(path) #create scanner and processor when needed: self.scanner = False self.processor = False # # load database: self.scans_database = scans_database.scans_database() self.scans_database.load(path,'database.pkl') #get first dataset: self.current_dataset = self.scans_database.get_dataset(0) QtGui.QWidget.__init__(self, parent) self.setWindowTitle('labeling tool') left_layout = QtGui.QVBoxLayout() self.draw_widget = draw_widget(self.current_dataset.polygons, self.scans_database.get_path() + '/' + self.current_dataset.image_filename, self) title_layout = QtGui.QHBoxLayout() take_scan_button = QtGui.QPushButton('Scan') take_scan_button.setMaximumWidth(50) title_layout.addWidget(take_scan_button) self.connect(take_scan_button, QtCore.SIGNAL('clicked()'), self.slot_take_scan ) take_artag_image_button = QtGui.QPushButton('ARTag') take_artag_image_button.setMaximumWidth(50) title_layout.addWidget(take_artag_image_button) self.connect(take_artag_image_button, QtCore.SIGNAL('clicked()'), self.slot_take_artag_image ) button = QtGui.QPushButton('Import Img') title_layout.addWidget(button) self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_import_image ) label = QtGui.QLabel("View: ") title_layout.addWidget(label) self.display_3d_button = QtGui.QPushButton('3D') self.display_3d_button.setMaximumWidth(40) title_layout.addWidget(self.display_3d_button) self.connect(self.display_3d_button, QtCore.SIGNAL('clicked()'), self.slot_display_3d ) combobox = QtGui.QComboBox() combobox.addItem("Height", QtCore.QVariant("height")) combobox.addItem("Intensities", QtCore.QVariant("intensities")) #combobox.addItem("objects", QtCore.QVariant("objects")) combobox.addItem("Labels", QtCore.QVariant("labels")) combobox.addItem("Classifier range", QtCore.QVariant("range")) combobox.addItem("Classifier color", QtCore.QVariant("color")) combobox.addItem("Classifier all", QtCore.QVariant("all")) combobox.addItem("Classifier all+post", QtCore.QVariant("all_post")) combobox.addItem("Baseline algo", QtCore.QVariant("baseline")) combobox.addItem("h", QtCore.QVariant("h")) combobox.addItem("s", QtCore.QVariant("s")) combobox.addItem("v", QtCore.QVariant("v")) self.connect(combobox, QtCore.SIGNAL('currentIndexChanged(int)'), self.slot_update_display_3d_type) title_layout.addWidget(combobox) self.display_3d_type_combobox = combobox; self.display_3d_spheres_button = QtGui.QPushButton('3D_Spheres') title_layout.addWidget(self.display_3d_spheres_button) self.connect(self.display_3d_spheres_button, QtCore.SIGNAL('clicked()'), self.slot_display_3d_spheres ) self.display_intensity_button = QtGui.QPushButton('Intensity') self.display_intensity_button.setMaximumWidth(50) title_layout.addWidget(self.display_intensity_button) self.connect(self.display_intensity_button, QtCore.SIGNAL('clicked()'), self.slot_display_intensity ) self.display_features_button = QtGui.QPushButton('Features') title_layout.addWidget(self.display_features_button) self.display_features_button.setMaximumWidth(50) self.connect(self.display_features_button, QtCore.SIGNAL('clicked()'), self.slot_display_features ) self.display_labels_button = QtGui.QPushButton('Labels') title_layout.addWidget(self.display_labels_button) self.display_labels_button.setMaximumWidth(50) self.connect(self.display_labels_button, QtCore.SIGNAL('clicked()'), self.slot_display_labels ) ### self.display_masks_button = QtGui.QPushButton('Masks') title_layout.addWidget(self.display_masks_button) self.display_masks_button.setMaximumWidth(50) self.connect(self.display_masks_button, QtCore.SIGNAL('clicked()'), self.slot_display_masks ) ### self.display_stats_button = QtGui.QPushButton('Stats') title_layout.addWidget(self.display_stats_button) self.display_stats_button.setMaximumWidth(50) self.connect(self.display_stats_button, QtCore.SIGNAL('clicked()'), self.slot_display_stats ) self.display_global_stats_button = QtGui.QPushButton('Global Stats') title_layout.addWidget(self.display_global_stats_button) self.display_global_stats_button.setMaximumWidth(50) self.connect(self.display_global_stats_button, QtCore.SIGNAL('clicked()'), self.slot_display_global_stats ) self.line_edits = [] self.add_line_edit('Title:',title_layout,'title') first_dataset_button = QtGui.QPushButton('<<') first_dataset_button.setMaximumWidth(30) title_layout.addWidget(first_dataset_button) self.connect(first_dataset_button, QtCore.SIGNAL('clicked()'), self.slot_first_dataset ) prev_dataset_button = QtGui.QPushButton('<') prev_dataset_button.setMaximumWidth(30) title_layout.addWidget(prev_dataset_button) self.connect(prev_dataset_button, QtCore.SIGNAL('clicked()'), self.slot_prev_dataset ) next_dataset_button = QtGui.QPushButton('>') next_dataset_button.setMaximumWidth(30) title_layout.addWidget(next_dataset_button) self.connect(next_dataset_button, QtCore.SIGNAL('clicked()'), self.slot_next_dataset ) last_dataset_button = QtGui.QPushButton('>>') last_dataset_button.setMaximumWidth(30) title_layout.addWidget(last_dataset_button) self.connect(last_dataset_button, QtCore.SIGNAL('clicked()'), self.slot_last_dataset ) save_button = QtGui.QPushButton('Save') title_layout.addWidget(save_button) save_button.setMaximumWidth(50) self.connect(save_button, QtCore.SIGNAL('clicked()'), self.slot_save ) delete_button = QtGui.QPushButton('Delete') title_layout.addWidget(delete_button) delete_button.setMaximumWidth(50) self.connect(delete_button, QtCore.SIGNAL('clicked()'), self.slot_delete ) self.connect(self.draw_widget, QtCore.SIGNAL('sigPolyChanged'), self.slot_update_polygons) self.connect(self.draw_widget, QtCore.SIGNAL('sigPolyLabelChanged'), self.slot_update_polygon_label) self.connect(self.draw_widget, QtCore.SIGNAL('sigDefineGroundPlane'), self.slot_define_ground_plane) left_layout.addLayout(title_layout) #second row: row2_layout = QtGui.QHBoxLayout() left_layout.addLayout(row2_layout) label = QtGui.QLabel("Id:") row2_layout.addWidget(label) self.id_label = QtGui.QLabel("") row2_layout.addWidget(self.id_label) self.add_line_edit('Surface: ID:',row2_layout,'surface_id') self.add_line_edit('Height',row2_layout,'surface_height') label = QtGui.QLabel("Type: ") row2_layout.addWidget(label) combobox = QtGui.QComboBox() combobox.addItem("Table Office", QtCore.QVariant("table_office")) combobox.addItem("Table Dorm", QtCore.QVariant("table_dorm")) combobox.addItem("Table House", QtCore.QVariant("table_house")) combobox.addItem("Shelf Office", QtCore.QVariant("shelf_office")) combobox.addItem("Shelf Dorm", QtCore.QVariant("shelf_dorm")) combobox.addItem("Shelf House", QtCore.QVariant("shelf_house")) self.connect(combobox, QtCore.SIGNAL('currentIndexChanged(int)'), self.slot_update_surface_type) row2_layout.addWidget(combobox) self.surface_type_combobox = combobox; self.add_line_edit('Camera: Height:',row2_layout,'camera_height') self.add_line_edit('Camera: Angle:',row2_layout,'camera_angle') ##################################### #thrid row: row3_layout = QtGui.QHBoxLayout() left_layout.addLayout(row3_layout) #checkboxes: button = QtGui.QPushButton("&gen'n'save features") row3_layout.addWidget(button) self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_generate_save_features ) checkbox = QtGui.QCheckBox('&Training Set') row3_layout.addWidget(checkbox) self.connect(checkbox, QtCore.SIGNAL('stateChanged(int)'), self.slot_update_training_set) self.checkbox_training_set = checkbox checkbox = QtGui.QCheckBox('Te&st Set') row3_layout.addWidget(checkbox) self.connect(checkbox, QtCore.SIGNAL('stateChanged(int)'), self.slot_update_test_set) self.checkbox_test_set = checkbox checkbox = QtGui.QCheckBox('Labels, Groundp. checked') row3_layout.addWidget(checkbox) self.connect(checkbox, QtCore.SIGNAL('stateChanged(int)'), self.slot_update_is_labeled) self.checkbox_is_labeled = checkbox button = QtGui.QPushButton("Train'n'save Classifiers (training set)") row3_layout.addWidget(button) self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_train_and_save_Classifiers ) button = QtGui.QPushButton('Test Classifiers (on current)') row3_layout.addWidget(button) self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_test_Classifiers ) button = QtGui.QPushButton('Test Classifiers (on testset)') row3_layout.addWidget(button) self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_test_Classifiers_on_testset ) button = QtGui.QPushButton('Load Classifiers') row3_layout.addWidget(button) self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_load_Classifiers ) # button = QtGui.QPushButton('Save Classifier') # row3_layout.addWidget(button) # self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_save_Classifier ) ##################################### left_layout.addWidget(self.draw_widget) self.right_layout = QtGui.QVBoxLayout() self.right_layout.setAlignment(QtCore.Qt.AlignTop) self.outer_layout = QtGui.QHBoxLayout() self.outer_layout.addLayout(left_layout) self.outer_layout.addLayout(self.right_layout) self.polygon_comboboxes = [] self.add_polygon_combobox() self.slot_update_polygons(self.current_dataset.polygons,0) self.setLayout(self.outer_layout) self.resize(900, 700) self.load_values_from_dataset() self.init_in_progress = False #at startup, display newest: self.slot_last_dataset()
fx = cp['focal_length_x_in_pixels'] fy = cp['focal_length_y_in_pixels'] cam_proj_mat = np.matrix([[fx, 0, 0, 0], [0, fy, 0, 0], [0, 0, 1, 0]]) cam_centers = ( cp['optical_center_x_in_pixels'], cp['optical_center_y_in_pixels'] ) #take image and scan import scanner import configuration #id = '2009Nov04_144041' id = '2009Nov04_135319' cfg = configuration.configuration('/home/martin/robot1_data/usr/martin/laser_camera_segmentation/labeling') img = hg.cvLoadImage(cfg.path + '/data/' + id + '_image.png') thok_dict = ut.load_pickle(cfg.path + '/data/' + id + '_laserscans.pkl') #cfg = configuration.configuration('/home/martin/robot1_data/usr/martin/laser_camera_segmentation/calib') #cfg.webcam_id = 0 #sc = scanner.scanner(cfg) #sc.capture_and_save('calib', False) #img = hg.cvLoadImage('/home/martin/robot1_data/usr/martin/laser_camera_segmentation/calib/data/calib_image.png') #thok_dict = ut.load_pickle('/home/martin/robot1_data/usr/martin/laser_camera_segmentation/calib/data/calib_laserscans.pkl') poses, scans = thok_dict['laserscans'][0] points_cloud_laser = p3d.generate_pointcloud(poses, scans, math.radians(-180), math.radians(180), 0, .035, max_dist=5.0, min_dist=.1) c = laser_cam_callib.Callib(cameraTlaser, seeds, deltas, names, points_cloud_laser, img, cam_proj_mat, cam_centers,1, id) while not c.reDraw():
def __init__(self): self.auto_langs = configuration('auto_trans_langs').split(',') self.auto_lang_count = len(self.auto_langs)
import sys if len(sys.argv) != 4: print "Usage: python midcom.py configuration sitegroup host" sys.exit() cnc = midgard.connection() cnc.open(sys.argv[1]) if cnc.set_sitegroup(sys.argv[2]) == False: print ("Sitegroup %s not found" % (sys.argv[2])) sys.exit() qb = midgard.query_builder('midgard_host') qb.add_constraint('name', '=', sys.argv[3]) res = qb.execute() if len(res) == 0: print ("Host %s not found" % (sys.argv[3])) sys.exit() host = res[0] # Testing cache cache = cache_midgard.cache_midgard(cnc, host) cache.delete_all('test') cache.delete('test_domain', 'test') # Testing configuration conf = configuration.configuration() conf.load_component_configuration("midgardmvc_core") print conf.get('authentication_configuration', 'fallback_translation')
def __init__(self,app): gui.QWidget.__init__(self) self.icons={} self.icons['Disconnected'] = gui.QIcon('img/disconnected.svg') self.icons['ConnectedUpdated'] = gui.QIcon('img/connectedupdated.svg') self.icons['ConnectedUpdating'] = (gui.QIcon('img/connectedupdating1.svg'),gui.QIcon('img/connectedupdating2.svg')) self.icons['PartialConnectedUpdating'] = (gui.QIcon('img/partialconnectedupdating1.svg'),gui.QIcon('img/partialconnectedupdating2.svg')) self.icons['PartialConnectedUpdated'] = gui.QIcon('img/partialconnectedupdated.svg') self.progress = gui.QMovie('img/progress.gif') self.tray = gui.QSystemTrayIcon(self.icons['Disconnected']) self.app = app #Loading configuration files cfgfile = os.path.join(self.configDir(),'.pyrsyncgui') servcfgfile = os.path.join(self.configDir(),'.pyrsyncgui.server') schedcfgfile = os.path.join(self.configDir(),'.pyrsyncgui.sync') self.config = conf.configuration(cfgfile) if len(self.config) == 0: self.defaultconfig() self.serverconfig = conf.configuration(servcfgfile) if len(self.serverconfig) == 0: self.defaultserverconfig() self.schedconfig = conf.configuration(schedcfgfile) if len(self.schedconfig) == 0: self.defaultschedconfig() self.window = uic.loadUi('gui.ui') self.connect(self.window.AddSyncButton, core.SIGNAL('clicked()'), self, core.SLOT('addSync()')) self.connect(self.window.ManageButton, core.SIGNAL('clicked()'), self, core.SLOT('manageSync()')) self.connect(self.window.ConfigButton, core.SIGNAL('clicked()'), self, core.SLOT('config()')) disp.register('SyncProgress',self.syncprogressupdate) disp.register('InfoMsg',self.infomsg) self.serverstatus = 0 self.backupstatus = 0 disp.register('ServerStatus',self.__serverStatusUpdate) disp.register('BackupStatus',self.__backupStatusUpdate) self.bckeng = backupengine(self.config,self.serverconfig,self.schedconfig) self.app.aboutToQuit.connect(self.cleanup) self.menu = gui.QMenu() self.menu.addAction('Pause Backups',self.__pauseBackups) self.menu.addSeparator() self.menu.addAction('Exit', self.quit) self.tray.activated.connect(self.__trayActivated) self.tray.setContextMenu(self.menu) self.tray.show() self.window.closeEvent = self.closing self.window.ServerVerifyButton.raise_() self.window.ServerVerifyInProgress.setMovie(self.progress) self.window.ServerProceedButton.raise_() self.window.ServerProceedInProgress.setMovie(self.progress) self.progress.start() self.currentwizard=None self.updateGraphics.connect(self.__updateGraphics) self.updateInfo.connect(self.__updateInfo) self.bckeng.start() self.window.InfoLabel.setText(' Welcome to pyrsyncgui!')
def main(): if len(sys.argv) < 2: sys.exit('Usage: %s savedb field' % sys.argv[0] + '\n') full_path = os.path.realpath(__file__) #Se averigua la ruta a manager.py dirname = os.path.dirname(full_path) #se obtiene el directorio config = configuration.configuration(dirname + '/Resources/timantti.conf') options = config.configSection('Database') #se obtienen los valores del archivo de configuracion genericDB = DB.databaseHandlerTable(options.get('host'),options.get('user'),options.get('pass'),options.get('db'),options.get('table')) #crea la conexion a la base de datos leyendo los datos desde el archivo de configuracion specificDB = DB.databaseHandlerTable(options.get('host'),options.get('user'),options.get('pass'),options.get('db'),table=sys.argv[1]) #crea la conexion a la base de datos leyendo los datos desde el archivo de configuracion root_tag = genericDB.readRoot(sys.argv[1]) saveas_tag = genericDB.readSaveas(sys.argv[1]) print root_tag[0][0] print saveas_tag[0][0] handler = XGH.xmlGenericHandler(pathtofile = os.path.dirname(os.path.realpath(__file__)) + '/' + saveas_tag[0][0]) #inicializa el handler de la base de datos--> se pasa la ruta absoluta tags=[] aux_tags = genericDB.readTags(sys.argv[1]) #arma los tags para insertar en la tabla correspondiente a la fuente for tag in aux_tags: tags.append(tag[0]) print tags values = handler.getBody(root_tag[0][0],tags) #obtiene los datos del XML especifico finish = False x = len(tags) - 1 i = 0 z = len(tags) while not finish: valor_bd = '(' + "'" + "','".join(values[i:z]) + "'" + ')' #arma la cadena para insertar los valores y el primer campo <tag> #valor_bd.decode('utf8') #print MySQLdb.escape_string(valor_bd) if (values[x] <> 'finarbol'): #agregado para corregir bug en algunos feeds donde se incluye el finarbol specificDB.insertItemDistinct(tags,valor_bd) #inserta en la base de datos hasta el primer <tag> x += 1 if len(values) > len(tags): #comprueba si hay mas de un tag while ((values[x] <> 'finarbol')): #quedan mas tags values_add = "','".join(values[i:z - 1]) valor_bd = '(' + "'" + (values_add) + "','" + values[x] + "'" + ')' #valor_bd.decode('utf8') if (values[x] <> 'finito'): #agregado para corregir bug en algunos feeds donde se incluye el finito specificDB.insertItemDistinct(tags,valor_bd) #inserta en la tabla el otro <tag> x+=1 if (values[x + 1] == 'finito'): finish = True else: i = x + 1 z = i + len(tags) x = z - 1 else: finish = True
# this software and its documentation without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of this work, and to # permit persons to whom this work is furnished to do so, subject to # the following conditions: # # - Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # - Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # - The authors' names may not be used to endorse or promote products derived # from this software without specific prior written permission. # # THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK # DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING # ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT # SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE # FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN # AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF # THIS SOFTWARE. ################################################################################ import configuration # instantiate one object of this class cfg = configuration.configuration()
def configuration(self, *args, **kwargs): """ Opens the global settings dialogue.""" d = configuration.configuration(self.session) if d.response == widgetUtils.OK: d.save_configuration()