def set(self, cursor=None, facebook_id=None, user_id=None, venue_id=None, name=None, address=None, country=None, phone=None, email=None, email_verified=None, category_id=None, headline=None, tonight=None, website=None, facebook=None, twitter=None, v_facebook_id=None, twitter_id=None, twitter_token=None, twitter_secret=None, lat=None, lon=None, official=None, verified=None, customer_spend=None, authenticated=None, creator_version=None, **kwargs): data = {'name': name, 'address': address, 'country': country, 'phone': phone, 'email': email, 'email_verified': util.to_bool(email_verified), 'category_id': util.to_int(category_id), 'headline': headline, 'tonight': tonight, 'website': website, 'facebook': facebook, 'twitter': twitter, 'facebook_id': v_facebook_id, 'twitter_id': twitter_id, 'twitter_token': twitter_token, 'twitter_secret': twitter_secret, 'lat': util.to_float(lat), 'lon': util.to_float(lon), 'official': util.to_bool(official), 'verified': util.to_bool(verified), 'customer_spend': util.to_float(customer_spend), 'authenticated': util.to_bool(authenticated), 'creator': user_id, 'creator_version': creator_version} columns = [] values = [] for key, val in data.iteritems(): if val != None: columns.append(key) values.append(val) if venue_id: qry = {'update': 'venues', 'set_values': columns, 'where': 'id = ?'} values.append(venue_id) cursor.execute(util.query(**qry), values) else: qry = {'insert_into': 'venues', 'columns': columns} cursor.execute(util.query(**qry), values) cursor.execute(util.query(last_id=True)) return int(cursor.fetchone().identity)
def main(): args = set_args() dest = args.destination_path + '.json' if os.path.isfile(dest) and not args.force: if input("'%s' already exists. Do you want to override it? [y/n]: " % args.destination_path) != 'y': print('exiting') exit(4) file = open(dest, 'w') cap = extract_video.get_capture(args.capture_path) if cap is None or cap.get(cv2.CAP_PROP_FPS) == 0: if extract_video.youtube_url_validation(args.capture_path): print( "Cannot access video in URL. Please check the URL is a valid YouTube video" ) exit(2) print( "Cannot access video in file. Please make sure the path to the file is valid" ) exit(3) get_data(cap, file, to_float(args.launch_time), args.out, args.destination_path)
def get_table_data(self): return [ t for t in ((it[0], to_float(it[1].text())) for it in ((i + 1, self.item(i, 0)) for i in range(0, self.rowCount())) if it[1]) if t[1] ]
def get_section_object(data_object): seat_count = -1 section = Section() section.code = str(data_object['course_id']) section.description = data_object['title'] section.details_url = helper.get_external_url( data_object['course_id'], data_object['slug'], ImportHistoryDataKeys.suites) section.registration_form_data = get_registration_form_data( data_object) section.start_date = None section.end_date = None section.num_seats = seat_count section.available_seats = seat_count section.execution_mode = ExecutionModes.SELF_PACED.value section.execution_site = None section.is_active = True section.registration_deadline = datetime.now() + timedelta( days=30) # ToDo: Find a way to add month section.instructors = [] section.schedules = [] section.course_fee = get_course_fee(data_object['course_price']) section.ceu_hours = util.to_float(data_object['ceu']) section.load_hours = convert_string_to_hours(data_object['length']) return section
def _by_population(feature): wkb, properties, fid = feature default_value = -1000 population_flt = to_float(properties.get('population')) if population_flt is not None: return int(population_flt) else: return default_value
def get_rows_by_val(self, val): '''doc''' val = to_float(val) ret = [] row_list = self.num_col_data.get("ROW_LIST") row_val_dict = self.num_col_data.get("ROW_VAL_DICT") for row_index in row_list: find_val = row_val_dict.get(row_index) if find_val == val: ret.append(row_index) return ret
def __init__(self, station, passcode, latitude, longitude, station_type, server_list=default_servers, post_interval=600): """ Initializer for the CWOPThread class. Required parameters: queue: An instance of Queue.Queue where the records will appear. station: The name of the station. Something like "DW1234". passcode: Some stations require a passcode. latitude: Latitude of the station in decimal degrees. longitude: Longitude of the station in decimal degrees. station_type: The type of station. Generally, this is the driver symbolic name, such as "Vantage". Optional parameters: server_list: A list of strings holding the CWOP server name and port. Default is ['cwop.aprs.net:14580', 'cwop.aprs.net:23'] post_interval: How long to wait between posts. Default is 600 (every 10 minutes). max_backlog: How many records are allowed to accumulate in the queue before the queue is trimmed. Default is sys.maxint (essentially, allow any number). log_success: If True, log a successful post in the system log. Default is True. log_failure: If True, log an unsuccessful post in the system log. Default is True. max_tries: How many times to try the post before giving up. Default is 3 timeout: How long to wait for the server to respond before giving up. Default is 10 seconds. max_tries: How many times to try the post before giving up. Default is 3 retry_wait: How long to wait between retries when failures. Default is 5 seconds. """ # Initialize my superclass super(CWOPThread, self).__init__(protocol_name="CWOP", post_interval=post_interval) self.station = station self.passcode = passcode self.server_list = server_list self.latitude = to_float(latitude) self.longitude = to_float(longitude) self.station_type = station_type
def convert_string_to_hours(length): hour = util.to_float(str(length).replace(' hours', '')) return hour
def get_course_fee(price): return CourseFee(amount=util.to_float(price['list_price']), currency='USD')
def get_float_val(self): '''doc''' val = self.get_val() return to_float(val)