def __init__(self, argv, base=None): """ main method @param argv: values of inline arguments """ if (base == None): path = __file__.split('/') base = '/'.join(path[:-1]) + '/' CommandLineUI.__init__(self, 'swaml', base) self.config = Configuration() for arg in argv: if arg == "-h" or arg == "--help": self.usage() elif arg == "-v" or arg == "--version": self.version() self.config.setAgent( 'http://swaml.berlios.de/doap.rdf') #TODO: how __init__.__agent__? self.parseArgs(argv) self.list = MailingList(self.config) messages = self.list.publish() print str(messages), 'messages procesed'
def __init__(self, argv): """ main method @param argv: values of inline arguments """ self.config = Configuration() args_ret = self.args(argv, self.config) self.pub = Publisher(self.config) print str(self.pub.publish()), 'messages procesed'
def __init__(self, argv): """ main method @param argv: values of inline arguments """ self.config = Configuration() self.config.setAgent(__url__) self.parseArgs(argv) self.list = MailingList(self.config) messages = self.list.publish() print str(messages), 'messages procesed'
def requestData(self): """ Queries the user a new configuration """ self.config = Configuration() print 'Write your configuration options:' print '(default value goes between [...])' for var in self.config.config.keys(): defaultValue = str(self.config.config[var]) value = raw_input('\t - ' + var + '[' + defaultValue + ']: ') if (len(value) > 0): self.config.set(var, value)
def __init__(self, district_id): if district_id == 1: self.district = district_1 elif district_id == 2: self.district = district_2 elif district_id == 3: self.district = district_3 elif district_id == 4: self.district = district_4 else: return False self.world = Configuration(district_id) self.batteries = self.district["batteries"] self.houses = self.district["houses"] self.costs = 0 self.violation = 0
def __init__(self, district_id): if district_id == 1: self.district = district_1 elif district_id == 2: self.district = district_2 elif district_id == 3: self.district = district_3 elif district_id == 4: self.district = district_4 else: return False self.batteries = [] self.world = Configuration(district_id) lists = self.world.get_lists() for battery0 in lists[0]: self.batteries.append(battery0[2]) self.houses = self.district["houses"] self.costs = 0
def testConfiguration(): print "\n****TEST CONFIGURATION****" rootDirectory = "./resources/test/configurations" files = Configuration.listConfigurationFiles(rootDirectory) selection = Configuration.userSelection(files) selectionFilepath = os.path.join(rootDirectory, files[selection]) configuration = Configuration(selectionFilepath) #Template configuration useTemplate = configuration.getUseTemplate() templateName = configuration.getTemplateName() templateColor = configuration.getTemplateColor() #Printer configuration printerOsName = configuration.getPrinterOsName() printerOsFormat = configuration.getPrinterOsFormat() printerDpiStretch = configuration.getPrinterDpiStretch() printerMargin = configuration.getPrinterMargin() printerMarginDimension = configuration.getPrinterMarginDim() printerMarginTemplate = configuration.getPrinterMarginTemplate() printerMarginPhoto = configuration.getPrinterMarginPhoto() assert (len(files) > 0) #Test Printer configuration assert (printerOsName == "Canon_CP900") assert (printerOsFormat == "\"Postcard(4x6in)\"") #Test Format configuration assert (useTemplate) assert ( templateName == "./resources/test/template/COR-NOV16_elements-template-instagram_FLASH-gimp.jpg" ) assert (templateColor == (216, 123, 98)) assert (printerDpiStretch) assert (printerMargin == (-1, -1)) assert (printerMarginDimension == "mm") assert (printerMarginTemplate == (30, 30)) assert (printerMarginPhoto == (60, 60)) print configuration print "TESTS ON CONFIGURATION PASSED SUCCESSFULLY"
def __init__(self, argv): """ main method @param argv: values of inline arguments """ self.config = Configuration() for arg in argv: if arg == "-h" or arg == "--help": self.usage() elif arg == "-v" or arg == "--verbose": self.config.set('verbose', True) self.config.setAgent('http://swaml.berlios.de/doap.rdf') self.parseArgs(argv) self.list = MailingList(self.config) messages = self.list.publish() print str(messages), 'messages procesed'
def main(): #The root directory inputDir = "/Users/manu/Desktop/wistiti/" #The configuration file directory configDir = os.path.join(inputDir, "configurations") #USE CONFIGURATION FILE #Ask user for configuration files = Configuration.listConfigurationFiles(configDir) selection = Configuration.userSelection(files) selectionFilepath = os.path.join(configDir, files[selection]) cfg = Configuration(selectionFilepath) print cfg #templateFile = "./resources/test/template/COR-MARS16_elements-template-gimp.jpg" useTemplate = cfg.getUseTemplate() if (useTemplate == True): templateFile = cfg.getTemplateName() else: templateFile = "NoTemplate" #marginColor = (84,158,167) marginColor = cfg.getTemplateColor() #TODO = Manage difference between width and height margins templateMargin = cfg.getPrinterMarginTemplate()[0] photoMargin = cfg.getPrinterMarginPhoto()[0] #The printer if (cfg.getPrinterOsName() == "Canon_CP900"): printFormat = PrintFormat.SelphyCP900( dpiStretch=cfg.getPrinterDpiStretch()) elif (cfg.getPrinterOsName() == "Dai_Nippon_Printing_DP_DS620"): printFormat = PrintFormat.DNPDS620( dpiStretch=cfg.getPrinterDpiStretch()) elif (cfg.getPrinterOsName() == "DNPDS620"): print "No osname and osformat for this printer %s\n"\ "Change the configuration file. Quit" %(cfg.getPrinterOsName()) return else: print "No printer with this name %s, quit" % (cfg.getPrinterOsName()) return printFormat.setPrinterMargin(cfg.getPrinterMargin()[0], cfg.getPrinterMargin()[1], cfg.getPrinterMarginDim) print printFormat #END OF USE CONFIGURATION FILE #Add a margin on the template (add new pixel for printer margin) templateFile = addMarginOnTemplate(templateFile, templateMargin, marginColor=marginColor) #Get the subdirectories that include instagram pictures subDirArray = getImmediateSubdirectories(inputDir) #User chooses the subdirectory userIndexSelection = userSelectionInArray(subDirArray) inputDir = os.path.join(inputDir, subDirArray[userIndexSelection]) #Get the images list (jpg) files = listScreenShotFiles(inputDir) #Display information for user print "********************************" print "%s files found" % (len(files)) print files print "********************************" userInput = "" index = 0 if (len(files) == 0): print "No compatible file in this directory, quit..." return while (userInput != "q"): #Open the picture image filepath = os.path.join(inputDir, files[index]) (filepathWithoutExtension, extension) = os.path.splitext(filepath) #fileOutput = filepathWithoutExtension + "-python" + extension #print filepathWithoutExtension #print extension #print fileOutput #Add a photo on the template photoPath = addPhotoOnTemplate(filepath, templateFile, margin=photoMargin) im = Image.open(photoPath) #exif_data = im._getexif() #print im.info #print exif_data photo = Photo(im.size[0], im.size[1]) photo.computePpmm(printFormat) print "********************************" print "File %s on %s : %s" % (index + 1, len(files), files[index]) print photo fileOutput = generateFilepathWithSuffix(photoPath, "-CP900-print") im.save(fileOutput, 'jpeg', dpi=(photo.ppiX, photo.ppiY)) im2 = Image.open(fileOutput) #User choose the action userInput = raw_input("Print? print/next/display/quit [p/n/d/q]") #print "Resultat %s" % userInput if userInput == "p": print im2.info printCommand = Printer.computePrinterCommand( fileOutput, cfg.getPrinterOsName(), cfg.getPrinterOsFormat()) Printer.sendPrinterJob(printCommand) print "INFO : YOU CAN PRINT THE SAME IMAGE" elif userInput == "n": print "Next picture" index += 1 elif userInput == "d": print "Display" im.show() elif userInput == "q": print "Quit" else: print "Unknown command" if (index >= len(files)): userInput = "q" print "No more picture, quit..."
import yaml from pyasesm import ActiveLists from classes.logger import Logger from classes.configuration import Configuration from classes.helper import Helper from classes.misp import Misp from classes.arcsight import ArcSight LOGLEVEL='info' if __name__ == '__main__': logger = Logger() logger.customize(LOGLEVEL) config = Configuration('Script synchronize MISP with ArcSight.') config.run_parser() #logger.customize(config.get('loglevel')) proxy = config.get('proxy') proxy = {'http': config.get('proxy'), 'https': config.get('proxy')} misp = Misp(config.get('misp-url'), config.get('misp-key'), not config.get('misp-no-verify-cert')) misp.loadRules(config.get('rules-file')) misp.downloadOrganisations() misp.loadPriorities(config.get('priorities-file')) if config.get('input'): misp.loadAttributes(config.get('input')) else:
def __init__(self, district_id): self.world = Configuration(district_id)
def run(options, algorithm, statistics_values): #we need a fixed seed to keep the experiments reproducible #we choose the total number of passenger vehicles (osm.passenger.trips.xml file) logger.info('algorithm: ' + str(options.algorithm)) ev = statistics_values.ev logger.info('Chosen EV ' + str(ev)) ev_entered_in_simulation = False conf = Configuration(ev, options.scenario_folder) if options.prefix == 'staticdynamic': conf.set_staticdynamic() logger.info('tls order') logger.info([ conf.edges[edge]['tl']['name'] for edge in conf.edges_order if edge in conf.edges_with_tl ]) algorithm.setup(conf, statistics_values, ev) algorithm.configure() # return while traci.simulation.getMinExpectedNumber() > 0: step = int(traci.simulation.getTime()) statistics_values.update_cars_by_time(step, traci.vehicle.getIDCount()) algorithm.execute_before_step_simulation(step) logger.info('step ' + str(step)) traci.simulationStep() if not ev_entered_in_simulation: ev_entered_in_simulation, when_entered = track_vehicle( ev, options, step) if ev_entered_in_simulation and statistics_values.n_when_ev_enter < 0: algorithm.conf.update_values() statistics_values.n_when_ev_enter = traci.vehicle.getIDCount() - 1 statistics_values.update_vehicles_affected_by_ev_dispatch() algorithm.execute_step(step, ev_entered_in_simulation) if ev in traci.vehicle.getIDList(): statistics_values.update_vehicles_affected_by_ev() statistics_values.distance_travelled = traci.vehicle.getDistance( ev) statistics_values.update_vehicles_on_tl() logger.info('ev ' + str(ev) + ' has travelled ' + str(statistics_values.distance_travelled) + 'm') if ev in traci.simulation.getStartingTeleportIDList(): statistics_values.was_teleported = True if statistics_values.ev_end == -1 and ( traci.vehicle.getIDCount() <= 0 or (ev_entered_in_simulation and ev not in traci.vehicle.getIDList())): if ev_entered_in_simulation and ev not in traci.vehicle.getIDList( ): statistics_values.ev_end = step statistics_values.n_when_ev_left = traci.vehicle.getIDCount( ) - 1 statistics_values.ev_start = when_entered algorithm.finish() if statistics_values.was_teleported: logger.info(str(ev) + ' has been teleported!') statistics_values.n_of_teleporteds |= set( traci.simulation.getStartingTeleportIDList()) statistics_values.crossed_tls_by_ev = len(algorithm.conf._edges_with_tl) statistics_values.print_summary(ev) traci.close() sys.stdout.flush() logger.info('finished!') logger.info('ev(' + str(ev) + ') started ' + str(statistics_values.ev_start) + ' and ended ' + str(statistics_values.ev_end)) statistics_values.get_results(ev, step) statistics_values.generate_json(options.skip, algorithm.instance_name())
def __init__(self, district_numb): # loads the batteries and houses into district variable of type configuration self.the_district = Configuration(district_numb) self.the_district.create_district()