def startDrive(self, model_name): if not self.driver: model_path = os.path.join("~/models", model_name) self.driver = Driver.Driver(model_path, camera=self.raw, controller=self) self.driver.startDriving()
def __init__(self, gui, drvname): self.gui = gui gtk.Table.__init__(self, 10, 3, False) import Driver self.drv = Driver.Driver(drvname) self.info = self.drv.info() kv = KeyAndValue(self.info) kv.show() self.attach(kv, 0, 3, 0, 9) b_add = gtk.Button('Add') b_add.connect('clicked', self.callback_add, drvname) b_add.show() self.attach(b_add, 0, 1, 9, 10) b_rem = gtk.Button('Remove') b_rem.connect('clicked', self.callback_rem, drvname) b_rem.show() self.attach(b_rem, 1, 2, 9, 10) b_reload = gtk.Button('Reload') b_reload.connect('clicked', self.callback_reload, drvname) b_reload.show() self.attach(b_reload, 2, 3, 9, 10) #b_change = gtk.Button( 'Change' ) #b_change.show() #self.attach( b_change, 3, 4, 9, 10 ) self.show()
def park(self, regno, driver_age): try: if self.numOfOccupiedSlots < self.capacity: if regno in self.regnos: print( "The car registration number is not unique. Inform the cops !!!" ) exit(0) slotid = self.getEmptySlot() self.slots[slotid] = { "reg_no": Vehicle.Car(regno), "driver_age": Driver.Driver(driver_age) } self.slotid = self.slotid + 1 self.numOfOccupiedSlots = self.numOfOccupiedSlots + 1 self.regnos.append(regno) return slotid + 1 else: return -1 except AttributeError as error: print( "~~~ Please make sure to create the parking lot before retrieving the information from it." ) exit(0)
def setUpClass(cls): for device in Driver.get_device_info(): d = Driver.Driver(device) cls.driver = d.start_appium() cls.driver.implicitly_wait(30) cls.log = log.log() cls.log.info('test start') print "start"
def callupdate(self): t = Driver(self.source, self.destination, self.AdminName) t.ReachDestination() self.msg = QtWidgets.QMessageBox() self.msg.setIcon(QMessageBox.Information) self.msg.setWindowTitle("Info") self.msg.setText("Stage of this parcel is now change") self.msg.setStandardButtons(QMessageBox.Ok) self.msg.show() self.callDriverPage()
def saveNewPng(self): now = datetime.datetime.now() now_iso_format = now.isoformat(timespec="seconds") new_png_file_name = now_iso_format + "Z.png" path = os.path.join(self.path_to_dir, new_png_file_name) driver = Driver.Driver() driver.savePng(self.conf["url"], self.conf["css_selector"], path) del (driver) self.last["datetime"] = now_iso_format self.last["png_file_name"] = new_png_file_name self.last.save() shutil.copy(path, os.path.join(self.path_to_dir, "last.png"))
def startDrive(self, model_name): if not model_name: #model_name = "default.h5" model_name = "default" model_path = os.path.join(config.directories['models'], model_name) model_path = config.directories['models'] # This doesn't work. crashes when trying to load weights #if self.driver and model_path != self.driver.model_path: # self.driver = None if not self.driver: self.driver = Driver.Driver(model_path, camera=self.raw, controller=self, model_name=model_name) self.driver.startDriving()
def checkout_no_profile(self): timer = Timer(self.driver_settings.autofill_url) # timer.wait_until_start_time() bot = Driver(self.user_settings.driver_path, None, self.user_settings.headless, self.user_settings.delay) timer.start() bot.go_to(self.driver_settings.supreme_start_page) bot.select_style(self.selection.style, self.selection.keywords, self.driver_settings.supreme_start_page) bot.delay() # bot.select_size() bot.add_to_cart() bot.delay() bot.go_to(self.driver_settings.supreme_checkout) bot.check_page_checkout() bot.checkout_page_scan() bot.manual_autofill( profile_name=self.profile.name, profile_email=self.profile.email, profile_tel=self.profile.tel, profile_address=self.profile.address, profile_apt=self.profile.apt, profile_zip=self.profile.zip, profile_city=self.profile.city, profile_card=self.profile.card, profile_month=self.profile.month, profile_year=self.profile.year, profile_cvv=self.profile.cvv, safe_autofill=self.profile.safe_autofill ) # bot.process_payment() timer.end() timer.print_time()
def modadd(self, info): drvname = None try: drvname = self.manager.gui.note_right.drvname except AttributeError: pass import GUISelect dialog = GUISelect.argDialog(self.manager.gui, drvname) ret = dialog.run() if not ret[0] or not ret[1]: return #print ret #src = 2, dst = 3 file = 4 cimpp=56789 import Driver drv = Driver.Driver(ret[1]) drv.install(self.manager.send, ret[4], ret[2], ret[3], ret[5:9])
def callDriverUpdate(self): self.selecteditem = self.ui.tableWidget.selectedItems() a = self.selecteditem[0].text() b = self.selecteditem[1].text() c = self.selecteditem[2].text() t = Driver(a, b, self.AdminName) t.collected() self.window = QtWidgets.QWidget() self.ui = Ui_Form_Driver_Update() self.ui.setupUi(self.window) self.form.hide() self.window.show() self.ui.label_5.setText(a) self.ui.destination_input.setText(b) self.source = a self.destination = b self.ui.commandLinkButton.clicked.connect(self.callupdate)
def generate_driver(): if random.randint(1, 10000) < 10: x = y = 0 for row in level: for col in row: if col == 's': driver = Driver.Driver(0, 0.4, (0, -1), x, y, self.branchBlocks, self.leaders, self.drivers) if sprite.spritecollideany(driver, self.drivers) is None: self.drivers.add(driver) self.leaders.add(driver) for d in self.drivers: d.driver_add(driver) x += ROAD_WIDTH y += ROAD_HEIGHT x = 0
def checkout_with_profile(self): timer = Timer(self.driver_settings.autofill_url) # timer.wait_until_start_time() bot = Driver(self.user_settings.driver_path, self.user_settings.user, self.user_settings.headless, self.user_settings.delay) bot.go_to("https://www.google.com") bot.delay() bot.delay() bot.delay() bot.delay() timer.start() bot.go_to(self.driver_settings.supreme_start_page) bot.select_style(self.selection.style, self.selection.keywords, self.driver_settings.supreme_start_page) bot.delay() # bot.select_size() bot.add_to_cart() bot.delay() bot.go_to(self.driver_settings.supreme_checkout) bot.check_page_checkout() bot.check_autofill() bot.process_payment() timer.end() timer.print_time()
import random import threading import io import base64 # fuzz case. 1 fuzz case def fuzz(case, inp): # write out the input to temp files? # this let you see what is being produce # as the fuzzer going with open(f"/Users/tnorria/Desktop/SecureMonopolySWE681/src/corpus/tmp_inputs/tmp{case}", "w") as file: file.write(str(base64.b64encode(inp).decode('utf-8'))) username = f"fuzz-test{inp}" a = Driver() try : a.createUser(user = username , password = inp) # watch for False return aka any thing fail within except Exception as e: with open(f"./corpus/crashes/tmp{case}", "w") as crash_file: crash_file.write(str(base64.b64encode(inp).decode('utf-8'))) crash_file.write("\n\n\n\n"+str(e)+"\n") print("EXCEPTION!!!!") ''' fuzzing stuff '''
import numpy as np import T7_power_supply as ps import Driver import time """ motor_y_ID = 'USB0::0x1AB1::0x0E11::DP8C201000734::INSTR' motor_x_ID = 'USB0::0x1AB1::0x0E11::DP8C201000755::INSTR' time_tagger_ID """ motor_y_ID = 30000 motor_x_ID = 30002 time_tagger_ID = "FIO2" galvo = Driver.Driver() #galvo.set_position(1,1) #galvo.display_position() #galvo.set_current(1,1) #while True: # galvo.t7.ping_FIO("FIO2") #galvo.t7.ping_DAC(1000,0.5) galvo.scan_rectangle([2, 1, -2, -1], [20, 20]) """ start = time.time()
path1 = os.getcwd() path1 = os.path.join(path1, 'drivers.txt') listOfWorkers = [] file1 = open(path1, 'r') drivers = file1.read() drivers = drivers.split("\n") del drivers[len(drivers) - 1] print(drivers) for i in range(0, len(drivers)): drivers[i] = drivers[i].split("\t\t") print(drivers[i]) # listOfWorkers.append(Driver.Driver(drivers[i][0], drivers[i][1], drivers[i][2], # drivers[i][3], drivers[i][4], drivers[i][5], drivers[i][6])) #Zamiennie działające inicjalizacje listOfWorkers.append(Driver.Driver( drivers[i])) #listą lub pojedynczymi argumentami listOfWorkers[i].show() file1.close() #----------------------------------------------- #Wczytywanie z pliku do listy obiektow typu Task listOfTasks = [] courses = [] s = [] path2 = os.getcwd() path2 = os.path.join(path2, 'tasks.txt') file2 = open(path2, 'r') courses = file2.read()
# calling functions depending on type of argument if args.add_customer != None: driver.add_customer(args) elif args.login != None: driver.login(args) elif args.add_vendor != None: driver.add_vendor(args) elif args.add_dish != None: driver.add_dish(args) elif args.search_by_dish != None: driver.search_by_dish(args) elif args.search_by_restaurant != None: driver.search_by_restaurant(args) elif args.place_order != None: driver.place_order(args) elif args.get_all_orders_by_customer != None: driver.get_all_orders_by_customer(args) elif args.get_all_orders != None: driver.get_all_orders(args) elif args.get_all_vendors != None: driver.get_all_vendors(args) elif args.logout != None: driver.logout(args) def pair(self, arg): return [str(x) for x in arg.split(',')] driver = Driver.Driver() RestEasy()
def setup(self): bot = Driver(self.user_settings.driver_path, self.user_settings.user, self.user_settings.headless, self.user_settings.delay) bot.go_to(self.driver_settings.autofill_url) bot.stall()
# -*- coding: utf-8 -*- """ Created on Sun Jan 27 12:01:53 2019 @author: Guddu """ #from Block import SoftBlock as SB import Driver benchmarks = ['ami33', 'ami49', 'n100', 'n200', 'n300'] tiers = [2, 3, 4] B, N, T = Driver.Driver(benchmarks[1], tiers[2], 0.05) #Driver.PrintTiers(B) #print(density)
def generateFeatures(driversDataPath, driverLimit=10000): import os import glob driverIndex = 0 tripIndex = 0 ''' read drivers directory ''' for dId in sorted(os.listdir(driversDataPath)): print " driver: index %s name %s " % (driverIndex, dId) driver = Driver(driverIndex, dId) tripIndex = 0 ''' for each driver read the trip files, one file at a time and compute the features and stores them in the Trip object ''' folder = '%s/%s/*.csv' % (driversDataPath, dId) for f in sorted(glob.glob(folder)): #print " f: ", f fileName = os.path.basename(f) [name, ext] = os.path.splitext(fileName) tripMatrix = [] features = [] ''' data sample rate is 1 sec ''' tripMatrix = np.loadtxt(f, delimiter=',', skiprows=1) ''' distances ''' distances = getDistances(tripMatrix) medianDist = np.median(distances) meanDist = np.mean(distances) stdDist = np.std(distances) maxDist = distances.max() tripTime = len(tripMatrix) tripDist = distances.sum() #np.sum(distances) ''' distance features ''' features.append(tripDist) features.append(tripTime) features.append(maxDist) features.append(stdDist) features.append(meanDist) features.append(medianDist) variances = getPCAVariance(tripMatrix) xVariance = variances[0] yVariance = variances[1] ''' xy variance features ''' features.append(xVariance) features.append(yVariance) ''' stops ''' stopCount = getStops(tripMatrix) dataJumpCount = getDataJumps(distances) ''' stops and jumps features ''' features.append(stopCount) features.append(dataJumpCount) '''speeds ''' speeds = distances medianSpeed = np.median(speeds) meanSpeed = np.mean(speeds) maxSpeed = speeds.max() mimSpeed = speeds.min() stdSpeed = np.std(speeds) '''speeds features ''' features.append(maxSpeed) features.append(mimSpeed) features.append(stdSpeed) features.append(meanSpeed) features.append(medianSpeed) ''' accelerations - derivative of speed''' accels = np.diff(speeds) [minAccel, maxAccel, totalAccel] = getMinMaxPos(accels) [minDecel, maxDecel, totalDecel] = getMinMaxNeg(accels) ''' accelerations features ''' features.append(maxAccel) features.append(minAccel) features.append(totalAccel) features.append(maxDecel) features.append(minDecel) features.append(totalDecel) ''' jerks - derivative of acceleration''' jerks = np.diff(accels) [minAccelJerk, maxAccelJerk, totalAccelJerck] = getMinMaxPos(jerks) [minDecelJerk, maxDecelJerk, totalDecelJerck] = getMinMaxNeg(jerks) ''' jerk features ''' features.append(maxAccelJerk) features.append(minAccelJerk) features.append(totalAccelJerck) features.append(maxDecelJerk) features.append(minDecelJerk) features.append(totalDecelJerck) ''' angles ''' angles, originAngles = getAngles(tripMatrix) maxAngle = angles.max() minAngle = angles.min() totalAngle = angles.sum() meanAngle = np.mean(angles) medianAngle = np.median(angles) ''' angles features ''' features.append(maxAngle) features.append(minAngle) features.append(meanAngle) features.append(medianAngle) features.append(totalAngle) ''' angularVelocity ''' angularSpeeds = angles * speeds maxAngularSpeed = angularSpeeds.max() minAngularSpeed = angularSpeeds.min() medianAngularSpeed = np.median(angularSpeeds) meanAngularSpeed = np.mean(angularSpeeds) features.append(maxAngularSpeed) features.append(minAngularSpeed) features.append(meanAngularSpeed) features.append(medianAngularSpeed) ''' instantiate Trip object ''' trip = Trip(tripIndex, name, tripTime, tripDist) ''' add the feature list to the current trip''' trip.setFeatureList(features) ''' add the trip to the driver ''' driver.addTrip(trip) del trip #the local trip should be dealocated every loop tripIndex += 1 ''' add driver to the manager. At this point the driver has all the trips with the corresponding features ''' driverMgr.addDriver(driver) del driver #the local driver should be dealocated every loop driverIndex += 1 ''' to get out of the drivers loop - for testing only ''' if driverIndex > driverLimit: break
def getDriver(self, index): try: return self.drivers[index] except IndexError: return Driver.Driver()
from PixyCamget import * from PIDController import PIDController from Gyro import Gyro from Driver import * from PiStorms import PiStorms psm = PiStorms() gyro = Gyro(psm.BAS2) TurnPID = PIDController(1, 0, 0, 1) DrivePID = PIDController(1, 0, 0) pixy = Pixy() gyro.calibrate(1) driver = Driver(psm.BAM1, psm.BAM2, gyro, 3) while True: blocks = pixy.get_blocks() found_block = None largest_block_size = 0 for block in blocks: if block[1] != 1: # Check signature type continue current_size = block[4] * block[5] # Find block with largest area if current_size > largest_block_size: largest_block_size = current_size found_block = block if found_block == None: continue
assert test1.requests == [], "requests is not empty" # after run(), the request list would be the data in 3 batches test1.run() assert test1.requests != [], "request should have data" # let's see what is inside the reqeust list for i in test1.requests: print(i, end=", ") print() print("------end of test 1------") print() print("------test 2------") # by the test1, we make sure that the requests are read from the files correctly # next, we will test if multiple drivers can attatch to the center and get informed test2 = Center.Center("Test2", "B") a = Driver.Driver("a") b = Driver.Driver("b") c = Driver.Driver("c") test2.attach(a) test2.attach(b) test2.attach(c) # I didn't implement getter of driver list because it is not nessary # If we can be sure that all the drivers attached get the right information, what driver list is doesn't matter # so first we call run() to run the informing flow test2.run() # after run(), the reference of requests in Driver should be the same as the Center print("testing driver a...") assert id(a.requests) == id(test2.requests), "driver is not updated" print("pass") print("testing driver b...") assert id(b.requests) == id(test2.requests), "driver is not updated"
from Driver import * from Capabilities import * caps = Capabilities() caps.add_desired_capability('browserName', 'chrome') caps.add_chrome_option('binary', "C:\\Program Files (x86)\\Google Chrome\\Application\\chrome.exe") caps.add_desired_capability('platform', 'ANY') driver = Driver() driver.start(caps.capability, '9000', 'chrome') driver.navigate("http://www.duckduckgo.com") print(driver.get_url()) print(driver.get_title()) driver.fullscreen() driver.minimize() driver.maximize() # Start manipulating elements #search_input = driver.get_element('xpath', '//*[@id ="search_form_input_homepage"]') search_input = driver.get_element('id', 'search_form_input_homepag') #Change this search_button = driver.get_element('xpath', '//*[@id ="search_button_homepage"]') privacy = driver.get_element_by_property('class', 'js-popout-link js-showcase-popout ddgsi ddgsi-down') #duckduckgo_logo = driver.get_element('link text', 'About DuckDuckGo') #span = driver.get_element('tag name', 'span') #driver.click(duckduckgo_logo) #driver.back() #driver.click(span) #driver.back()
(lStart, lEnd) = face_utils.FACIAL_LANDMARKS_IDXS["left_eye"] (rStart, rEnd) = face_utils.FACIAL_LANDMARKS_IDXS["right_eye"] (mStart, mEnd) = face_utils.FACIAL_LANDMARKS_IDXS["mouth"] ######### 启动视频流线程 ###################### #遍历数据集文件 root = 'NTHU/glasses' for i in os.listdir(root): #获取文件路径 path = os.path.join(root, i) if os.path.isfile(path): print "***********************" print(path) #创建类对象 dA = Driver() #统计周期总时间 totalTime = 0.0 #人眼识别时间 eye_time = 0.0 #嘴部识别时间 mouth_time = 0.0 #头部识别时间 head_time = 0.0 #特征点定位时间 FP_time = 0.0 #错检帧数 errorFrameNum = 0 #存储眼部状态(0为闭眼,1为睁眼) eyeState = []
return parser.parse_args() if __name__ == "__main__": args = _parse_input() cnip_opt = dict(no_stdlib=args.no_stdlib, no_typedef=args.no_typedef, no_heuristic=args.no_heuristic, traces=args.trace, trace_level=args.trace_level, host_cc=args.CC, host_cc_cmd=args.command, dev_mode=args.dev) TraceManager().configure(cnip_opt['traces'], cnip_opt['trace_level']) env = EnvironmentController(os.path.expanduser('~')) env.check_all(args.non_commercial_use) if args.dev: run_dir = os.path.dirname(os.path.realpath(__file__)) os.environ['LD_LIBRARY_PATH'] = run_dir + '/../Plugin' os.environ['PATH'] += os.pathsep + run_dir + '/../External/PsycheC' # Let' go! driver = Driver(cnip_opt) code = driver.execute() sys.exit(code)