class SpinnerTest(unittest.TestCase): def testAssertCond(self): self.assert_(3 in range(4)) def synonymsTest(self, sApp, xData): if sApp == 'boss': aResults = [result[0] for result in xData['results']] sPhrase = xData['phrase'] nPage = xData['page'] assert len(aResults) == 50, len(aResults) if nPage is 0: assert len('wii sports cheats, codes, cheat codes for nintendo wii (nwii)') is len(aResults[13]), aResults[13] assert len('wii cheats, reviews, faqs, message boards, and more - gamefaqs') is len(aResults[0]), '"'+aResults[0]+'"' assert len('wii sports: cheats, cheat codes, tips & trainers! - cheating wii sports ...') is len(aResults[47]), '"'+aResults[47]+'"' #self.oSpin.aDrivers[sApp].oResults self.assertEqual(sPhrase, 'wii tips') kSynonyms = self.oSpin.synonyms(aResults, True) for sWord, aSynonyms in kSynonyms.iteritems(): print sWord, aSynonyms def testBoss(self): self.oSpin = Spinner() self.oSpin.search('wii tips', ['boss'], [self.synonymsTest])
def parse_cifar(output_dir, dataset, mode): features = [] labels = [] coarse_labels = [] batch_names = [] TARFILE, label_data, label_labels, label_coarse = get_data_params(dataset) datanames = get_datanames(dataset, mode) try: spinner = Spinner(prefix="Loading {} data...".format(mode)) spinner.start() tf = tarfile.open(output_dir + '/' + TARFILE) for dataname in datanames: ti = tf.getmember(dataname) data = unpickle(tf.extractfile(ti)) features.append(data[label_data]) labels.append(data[label_labels]) batch_names.extend([dataname.split('/')[1]] * len(data[label_data])) if dataset == 'cifar100superclass': coarse_labels.append(data[label_coarse]) features = np.concatenate(features) features = features.reshape(features.shape[0], 3, 32, 32) features = features.transpose(0, 2, 3, 1).astype('uint8') labels = np.concatenate(labels) if dataset == 'cifar100superclass': coarse_labels = np.concatenate(coarse_labels) spinner.stop() except KeyboardInterrupt: spinner.stop() sys.exit(1) return features, labels, coarse_labels, batch_names
def __init__(self, url): self.url = url self.spinner = Spinner() self.stream_url = None self.station_id = None self.ft = None self.to = None self.auth_token = None self.key_offset = None self.key_length = None self.partial_key = None self.auth_response_body = None self.area_id = None self.title = None
def main(): parser = build_parser() args = parser.parse_args() signal.signal(signal.SIGINT, signal_handler) global spinner spinner = Spinner() global THREAD_MAX THREAD_MAX = args.thread_max if args.omit_logs: log_file = "/dev/null" else: log_file = args.log_file numeric_log_level = getattr(logging, args.log_level.upper(), None) frmt = '%(levelname)s %(asctime)s %(module)s (%(funcName)s): %(message)s' logging.basicConfig( filename=log_file, level=numeric_log_level, format=frmt, datefmt="%Y-%m-%d %H:%M:%S" ) logging.info("Successful logging init") logging.info("Selected maximum number of threads: {}".format(THREAD_MAX)) parse_commands(args.commands, args.command_file, args.message)
class Console(object): """ Provides printing utilities. """ console_width = 100 spinner = Spinner.create_spinner(18, 100) @classmethod def print_str(cls, str_to_print, newline=False, override=True, spinner=False): """ Print without new line. """ if override: cls.eat_line(cls.console_width) if spinner: str_to_print = cls.spinner.next() + ' ' + str_to_print if newline: str_to_print += '\n' sys.stdout.write(str_to_print) sys.stdout.flush() @classmethod def eat_line(cls, num_to_eat): """ Print \b to eat words. """ sys.stdout.write('\b' * num_to_eat) sys.stdout.write(' ' * cls.console_width) sys.stdout.write('\b' * num_to_eat)
def _create_image_from_ebs(self, size=15): log.info("Creating EBS image...") imgid = self.ec2.create_image(self.host.id, self.name, self.description) log.info("Waiting for AMI %s to become available..." % imgid, extra=dict(__nonewline__=True)) img = self.ec2.get_image(imgid) s = Spinner() s.start() while img.state == "pending": time.sleep(15) if img.update() == "failed": raise exception.AWSError( "EBS image creation failed for AMI %s" % imgid) s.stop() return imgid
def _find_files(src_dir, suffixes, exclude_dirs=None, verbose=False): '''Search for files in a source directory based on one or multiple file suffixes. This function will only append a found file to the list if it exists (using os.path.exists) wich serves as a minimal test for checking if a file is broken. Parameters ---------- src_dir : str The source directory. suffixes : str, tuple of strs A single file suffix or tuple of file suffixes that should be searched for (e.g. '.jpeg' or ('.jpeg','.png')). exclude_dirs : str, list of str, None Name of single directory of list of directory names that should be ignored when searching for files. All of the specified directories and their children directories will be ignored (Default: None) verbose : bool If true, print spinning cursor Returns ------- filepath_list : list A list of all found filepaths ''' filepath_list = [] if verbose == True: with Spinner('Searching for files '): for (paths, dirs, files) in os.walk(src_dir): if exclude_dirs: dirs[:] = [d for d in dirs if d not in exclude_dirs] for file in files: filepath = os.path.join(paths, file) if filepath.lower().endswith(suffixes) and os.path.exists( filepath): filepath_list.append(filepath) if verbose == False: for (paths, dirs, files) in os.walk(src_dir): if exclude_dirs: dirs[:] = [d for d in dirs if d not in exclude_dirs] for file in files: filepath = os.path.join(paths, file) if filepath.lower().endswith(suffixes) and os.path.exists( filepath): filepath_list.append(filepath) if not filepath_list: sys.stdout.write('Did not find any files based on the given suffixes') sys.exit() return filepath_list
def print_spinner(text, spin_type, sleep=4): with Spinner(prefix=text, spinner_type=spin_type): time.sleep(sleep) dots = "..." if text.endswith('...'): dots = "" print(f"{text}{dots}DONE\n")
def get_module_dict(self, remoteUrl): """ Returns a dictionary of module(key):version(value) of server side modules. """ moduleDict = {} spinner = Spinner() remoteModuleList = self.get_module_list(remoteUrl) count = 1 for moduleName in remoteModuleList: spinner.render(count) urlFull = "{0}/{1}".format(remoteUrl, moduleName) moduleVersion = self.get_module_version(urlFull) moduleDict[str(moduleName)] = str(moduleVersion) count = count + 1 return moduleDict
def get_module_dict(self, remoteUrl): """ Returns a dictionary of module(key):version(value) of server side modules. """ moduleDict = {} spinner = Spinner() remoteModuleList = self.get_module_list(remoteUrl) count = 1 for moduleName in remoteModuleList: spinner.render(count) urlFull = '{0}/{1}'.format(remoteUrl, moduleName) moduleVersion = self.get_module_version(urlFull) moduleDict[str(moduleName)] = str(moduleVersion) count = count + 1 return moduleDict
def info(self, xiinArgDict): """ Walks the directory. """ print("Getting info") print('') spinner = Spinner() count = 1 for root, dirs, files in os.walk(xiinArgDict.directory): for file in files: xiinArgDict.fullPathFile = os.path.join(root, file) self.__readFile(xiinArgDict) # show spinner when writing files if not xiinArgDict.display: spinner.render(count) count = count + 1
def login(): global home global config global login_config subdomain = click.prompt( f"{Fore.MAGENTA}Subdomain", default=config.get("host")) username = click.prompt(f"{Fore.MAGENTA}Username", default=login_config.get("username")) password = click.prompt( f"{Fore.MAGENTA}Password", hide_input=True) config["host"] = subdomain pickle.dump(config, open(f"{home}/.loopterm.conf", "wb")) login_config = {} s = Spinner("Logging in to School Loop...") s.start() try: r = requests.get(f"https://{subdomain}/mapi/login", params={"version": 3}, auth=requests.auth.HTTPBasicAuth(username, password)) except Exception: s.stop() msg = f"{Fore.RED}{Style.BRIGHT}Fatal Error! {Fore.BLUE}{Style.NORMAL}Couldn't connect to server. Check your internet connection and the subdomain entered." click.echo(msg) sys.exit(1) s.stop() if r.status_code == 401: msg = f"{Fore.RED}{Style.BRIGHT}Login failed! {Fore.BLUE}Check your username and password." click.echo(msg) elif r.status_code == 200: details = r.json() if details["isParent"] == False: msg = f"{Fore.RED}{Style.BRIGHT}Login error! {Fore.BLUE}{Style.NORMAL}Parent accounts do not work with LoopTerm." click.echo(msg) sys.exit(1) else: msg = f"{Style.BRIGHT}{Fore.GREEN}Login success! {Fore.BLUE}{Style.NORMAL}You are logged in as {Fore.YELLOW}{details['fullName']} {Fore.BLUE}at {Fore.YELLOW}{details['students'][0]['school']['name']}{Fore.BLUE}." login_config["password"] = password login_config["user_id"] = details['userID'] click.echo(msg) else: msg = f"{Fore.RED}{Style.BRIGHT}Error! {Fore.BLUE}{Style.NORMAL}Server returned error {Fore.YELLOW}{r.status_code}{Fore.BLUE}.\n{Fore.CYAN}{Style.BRIGHT}Response: {Fore.YELLOW}{Style.NORMAL}{r.text}" click.echo(msg) home = os.environ.get("HOME") login_config["username"] = username pickle.dump(login_config, open(f"{home}/.loopterm.login", "wb"))
def _local_go(self): self.logger.info("Starting local search...") if self.out_directory is None: self.logger.error("No directory specified. Abort!") return if self.stealth: # If stealth just display collected files. self.logger.info("List of files to analyze in \"{}\": ".format( self.out_directory)) working_dir = os.path.realpath(self.out_directory) for file_name in os.listdir(working_dir): print(" * " + file_name) else: print_string = "Analyzing local files..." stop_spinner = None spin_thread = None if not self.logger.can_log(): stop_spinner = threading.Event() spin_thread = Spinner(stop_spinner, prefix=print_string) spin_thread.start() working_dir = os.path.realpath(self.out_directory) for file in os.listdir(working_dir): self.input_queue.put(os.path.join(working_dir, file)) self._finish_work() if not self.logger.can_log( ) and stop_spinner is not None and spin_thread is not None: stop_spinner.set() spin_thread.join() self.logger.success(print_string + "DONE")
def cmd(args): _fs = Fs(args.host, args.db, args.user, args.password, args.bucket, args.ssl, args.auth_db) if exists(args.source): local_folder, local_files = _build_local_file_list(args.source) if len(local_files) > 0: # build remote gridFs prefix (prepend a '/' if required) remote_prefix = '' if len(args.prefix) > 0: remote_prefix = "/{0}".format( args.prefix ) if not args.prefix.startswith('/') else args.prefix for local_file in local_files: local = local_folder + local_file remote = remote_prefix + local_file src_file = open(local, 'r') spinner = Spinner() sys.stdout.write(remote + ': ') spinner.start() f_id = _fs.upload(src_file, remote) spinner.stop() sys.stdout.write(str(f_id) + '\n') else: print "No files to upload." else: print 'local file/folder [{0}] does not exists'.format(args.source)
def grades(period=None): global config global login_config host = config.get("host") s = Spinner("Connecting to School Loop...") s.start() # try: r = requests.get(f"https://{host}/mapi/report_card", params={"studentID": login_config["user_id"]}, auth=requests.auth.HTTPBasicAuth(login_config["username"], login_config["password"])) """ except Exception as e: s.stop() msg = f"{Fore.RED}{Style.BRIGHT}Fatal Error! {Fore.BLUE}{Style.NORMAL}Couldn't connect to server. Check your internet connection and the subdomain entered." click.echo(msg) sys.exit(1) """ s.stop() data = r.json() grades = [] if period: grades = [[pd["period"], pd["courseName"], pd["teacherName"], pd["grade"], pd["score"]] for pd in data if pd["period"] == period] else: grades = [[pd["period"], pd["courseName"], pd["teacherName"], pd["grade"], pd["score"]] for pd in data] click.echo(tabulate( [["#", "Course", "Teacher", "Mark", "Score"], *grades], headers="firstrow"))
def inject(url, payload, keyword, cookies): spin = Spinner() print("Attempting to inject payload...") spin.start() soup = make_soup(url, cookies) form = get_form(soup) if form != None: action = get_action(form, url) if action != None: data = get_form_data(form, payload) r = requests.post(action, data=data) spin.stop() print("Payload injected, POST request sent.") else: spin.stop() print( "No action parameter found, unable to automatically inject, attempting to crawl for payload now..." ) else: spin.stop() print("No forms found!") crawler.crawl(url, payload, keyword, cookies)
def main(): logger = ConsoleLogger() propertiespath = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'properties') generalproperties = ConfigHelper.config(None, path=propertiespath, filename='properties.ini', section='general') dbproperties = ConfigHelper.config(None, path=propertiespath, filename='database.ini', section=generalproperties.get('db')) dirpath = generalproperties.get('dirpath') watch_file_extension = generalproperties.get('watch_file_extension') asc_files = [f for f in os.listdir(dirpath) if f.endswith(watch_file_extension)] asc_files_with_path = [] for file in asc_files: asc_files_with_path.append(os.path.join(dirpath, file)) logger.info('found hydrograph-files: {}'.format(asc_files_with_path)) filecount = len(asc_files) logger.info('Number of forecast files found: {}'.format(filecount)) shapenames = [] if filecount > 0: filenames = asc_files_with_path for filename in filenames: filename = ProcessingHelper.replacebackslashes(filename) logger.info("filename {}".format(filename)) dataframe_forecast = ProcessingHelper.getDataFrameForFile(None, filename) floodplain_name = ProcessingHelper.getfloodplainNameFromFilename(filename) # Determine Interpolation function for infile and calculate max Q from infile and Volume from interpol-func qvol, err = ProcessingHelper.getVolume(dataframe_forecast) qmax = dataframe_forecast['q'].max() logger.info("Floodplain: {0}; Input-Hydrograph: Q [m3]: {1:n}; Qmax [m3/s]: {2:n}".format(floodplain_name, int(round(qvol)), qmax)) # match hydrograph from infile to SDH's via Qmax and Volume # grab matching shapefile from postgis-database and display it shapenames.append(ProcessingHelper.getmatchingshapefromdb(None, qmax, qvol, floodplain_name, dbproperties, logger)) filteredShapeNames = list(filter(None.__ne__, shapenames)) if len(filteredShapeNames) > 0: mergeprocessor = MergeProcessor() logger.info('Merging and dissolving starts ...') spinner = Spinner() spinner.start() mergetablename = mergeprocessor.exec_merge_dissolve(dbproperties, generalproperties, filteredShapeNames, logger) spinner.stop() logger.info('Merging and dissolving finished. Resulting tablename is {}.'.format(mergetablename)) sys.stdout.write(mergetablename) sys.stdout.flush() sys.exit(0) else: logger.error('No resulting shapes available. Processing finished.') sys.exit(1)
def main(): # create Excel workbook xlout = Workbook() xlout.active.title = "Coaster Masterlist" # preferred fixed-width font menlo = Font(name="Menlo") # list of tuples of the form (fullCoasterName, abbreviatedCoasterName) coasterDict = getCoasterDict(xlout.active, menlo) # create color key for designers if args.colorize: coasterdesignerws = xlout.create_sheet("Coaster Designer Color Key") i = 1 for designer in sorted(designers.keys()): if designer != "" and designer != "Other Known Manufacturer": coasterdesignerws.append([designer]) coasterdesignerws.cell(row=i, column=1).fill = designers[designer] i += 1 if "Other Known Manufacturer" in designers.keys(): coasterdesignerws.append(["Other Known Manufacturer"]) coasterdesignerws.cell( row=i, column=1).fill = designers["Other Known Manufacturer"] i += 1 if "" in designers.keys(): coasterdesignerws.append(["Other [Unknown]"]) coasterdesignerws.cell(row=i, column=1).fill = designers[""] coasterdesignerws.column_dimensions['A'].width = 30.83 # for each pair of coasters, a list of numbers of the form [wins, losses, ties, winPercent] winLossMatrix = createMatrix(coasterDict) processAllBallots(xlout, coasterDict, winLossMatrix) calculateResults(coasterDict, winLossMatrix) # sorted lists of tuples of the form (rankedCoaster, relevantNumbers) finalResults, finalPairs = sortedLists(coasterDict, winLossMatrix) # write worksheets related to finalResults, finalPairs, and winLossMatrix printToFile(xlout, finalResults, finalPairs, winLossMatrix, coasterDict, menlo, designers) # save the Excel file print("Saving...", end=" ") if useSpinner: spinner = Spinner() spinner.start() xlout.save(args.outfile) if useSpinner: spinner.stop() print('output saved to "{0}".'.format(args.outfile))
def find(self): """ Public find function that calls a "spinner" to show it's working and then print a summary of items found. Params: ------------- none """ with Spinner(self.counts): self._find(self.path) sys.stdout.write("\r") sys.stdout.write( " " * 200) # needs to be robust hard coded right now to erase line sys.stdout.write("\r\n") return self.results
def getBallotFilepaths(): print("Getting the filepaths of submitted ballots...", end=" ") if useSpinner: spinner = Spinner() spinner.start() ballotList = [] for file in os.listdir(args.ballotFolder): if file.endswith(".txt"): ballotList.append(os.path.join(args.ballotFolder, file)) if useSpinner: spinner.stop() print("{0} ballots submitted.".format(len(ballotList))) return ballotList
def cmd(args): _fs = Fs(args.host, args.db, args.user, args.password, args.bucket, args.ssl, args.auth_db) confirmation = args.confirmation files = _fs.find(args.filename) if len(files) > 0: print "Found {0} files to remove".format(len(files)) confirmed = _confirm_removal() if confirmation else False if not confirmation or confirmed: for f in files: spinner = Spinner() print f.filename spinner.start() _fs.rm(f._id) spinner.stop() else: print "no matching file found."
def createMatrix(coasterDict): print("Creating the win/loss matrix...", end=" ") if useSpinner: spinner = Spinner() spinner.start() winLossMatrix = {} for coasterA in coasterDict.keys(): for coasterB in coasterDict.keys(): # can't compare a coaster to itself if coasterA != coasterB: winLossMatrix[coasterA, coasterB] = {} winLossMatrix[coasterA, coasterB]["Wins"] = 0 winLossMatrix[coasterA, coasterB]["Losses"] = 0 winLossMatrix[coasterA, coasterB]["Ties"] = 0 winLossMatrix[coasterA, coasterB]["Win Percentage"] = 0.0 winLossMatrix[coasterA, coasterB]["Pairwise Rank"] = 0 if useSpinner: spinner.stop() print("{0} pairings.".format(len(winLossMatrix))) return winLossMatrix
def cmd(args): _fs = Fs(args.host, args.db, args.user, args.password, args.bucket, args.ssl, args.auth_db) gridfs_files = _fs.find(args.filename) nb_of_files = len(gridfs_files) if nb_of_files > 0: print 'downloading ' + str(nb_of_files) + ' files:' for gridfs_file in gridfs_files: gridfs_filename = gridfs_file.filename destination = args.destination + gridfs_filename # check for any non-existing parent directories for local destination, and create them destination_root = dirname(destination) if not exists(destination_root): makedirs(destination_root) spinner = Spinner() spinner.start() dst_file = open(destination, 'wb') _fs.download(gridfs_filename, dst_file) spinner.stop() print destination else: print "no matching file found."
class Radiko: auth_key = 'bcd151073c03b352e1ef2fd66c32209da9ca0afa' fms1_url = 'https://radiko.jp/v2/api/auth1_fms' fms2_url = 'https://radiko.jp/v2/api/auth2_fms' def __init__(self, url): self.url = url self.spinner = Spinner() self.stream_url = None self.station_id = None self.ft = None self.to = None self.auth_token = None self.key_offset = None self.key_length = None self.partial_key = None self.auth_response_body = None self.area_id = None self.title = None @spinner_decorator('Obtaining streaming url... ', 'done') def set_basic_info(self): options = Options() options.add_argument('--headless') driver = webdriver.Chrome(options=options) driver.get(self.url) html = driver.page_source.encode('utf-8') soup = BeautifulSoup(html, 'html.parser') hidden_input = soup.find('input', id='share-url') try: self.stream_url = str(hidden_input['value']) except TypeError: print('hidden_input is empty !! Try again !!') exit() pat = r'station_id=(?P<station_id>[A-Z]+.*)&ft=(?P<ft>[0-9]+)&to=(?P<to>[0-9]+)' match = re.search(pat, self.stream_url) if match: self.station_id = match.group('station_id') self.ft = match.group('ft') self.to = match.group('to') def authenticate(self): @spinner_decorator('Authenticating with auth1_fms... ', 'done') def auth1(): headers = { 'X-Radiko-App': 'pc_html5', 'X-Radiko-App-Version': '0.0.1', 'X-Radiko-User': '******', 'X-Radiko-Device': 'pc' } r = requests.post(url=self.fms1_url, headers=headers) if r.status_code == 200: response_headers = r.headers self.auth_token = response_headers['x-radiko-authtoken'] self.key_offset = int(response_headers['x-radiko-keyoffset']) self.key_length = int(response_headers['x-radiko-keylength']) else: print(' Status Code := {}'.format(r.status_code)) @spinner_decorator('Creating partial key file... ', 'done') def create_partial_key(): tmp_key = self.auth_key[self.key_offset:self.key_offset + self.key_length] self.partial_key = base64.b64encode( tmp_key.encode('utf-8')).decode('utf-8') @spinner_decorator('Authenticating with auth2_fms... ', 'done') def auth2(): headers = { 'X-Radiko-User': '******', 'X-Radiko-Device': 'pc', 'X-Radiko-Authtoken': '{}'.format(self.auth_token), 'X-Radiko-Partialkey': '{}'.format(self.partial_key), } r = requests.post(url=self.fms2_url, headers=headers) if r.status_code == 200: self.auth_response_body = r.text auth1() create_partial_key() auth2() def set_area_id(self): area = self.auth_response_body.strip().split(',') self.area_id = area[0] @spinner_decorator('Obtainig file title... ', 'done') def set_title(self): try: datetime_api_url = 'http://radiko.jp/v3/program/date/{}/{}.xml'.format( self.ft[:8], self.area_id) r = requests.get(url=datetime_api_url) if r.status_code == 200: channels_xml = r.content tree = ET.fromstring(channels_xml) station = tree.find('.//station[@id="{}"]'.format( self.station_id)) prog = station.find('.//prog[@ft="{}"]'.format(self.ft)) to = prog.attrib['to'] except AttributeError: n = datetime.strptime(self.ft[:8], '%Y%m%d') d = n - timedelta(days=1) datetime_api_url = 'http://radiko.jp/v3/program/date/{}/{}.xml'.format( d.strftime('%Y%m%d'), self.area_id) r = requests.get(url=datetime_api_url) if r.status_code == 200: channels_xml = r.content tree = ET.fromstring(channels_xml) station = tree.find('.//station[@id="{}"]'.format( self.station_id)) prog = station.find('.//prog[@ft="{}"]'.format(self.ft)) to = prog.attrib['to'] self.title = prog.find('.//title').text.replace(' ', '_').replace(' ', '_') def setup(self): self.set_basic_info() self.authenticate() self.set_area_id() self.set_title() def download(self): self.setup() cmd = ('ffmpeg ' '-loglevel fatal ' '-n -headers "X-Radiko-AuthToken: {}" ' '-i "{}" ' '-vn -acodec copy "{}.aac"'.format( self.auth_token, self.stream_url, self.ft[:8] + ' - ' + self.title)) print('Downloading {}.aac... '.format(self.title), end='') self.spinner.start() subprocess.call(cmd, shell=True) self.spinner.stop() print('done!')
def makeWindow(root, st): " make the top window for autogoal options" global ag tp = Toplevel(borderwidth=3, relief='ridge') tp.wm_title('Autogoal settings') try: tp.maxw = root.maxw tp.maxh = root.maxh - 30 except: v = root.geometry() parts = string.split(v, 'x') tp.maxw = int(parts[0]) partx = string.replace(parts[1], '-', '+') partx = string.split(parts[1], '+') tp.maxh = int(partx[0]) - 30 sizer = '%dx%d+0+25' % (tp.maxw, tp.maxh) tp.wm_geometry(sizer) #tp.overrideredirect(1) tp.transient(root) def _freeze_window(tp, geom, event, *args): if tp.wm_geometry() != geom: tp.wm_geometry(geom) tp.bind('<Configure>', Command(_freeze_window, tp, sizer)) wk = Frame(tp) for lt in range(len(st.fmt)): if lt >= len(st.autogoals): if st.fmt[lt] == 'R' or st.fmt[lt] == 'M': st.autogoals.append([65, 0, 250]) else: st.autogoals.append([20, 6, 250]) lst = st.autogoals[lt][:] #print lst makeit(wk, lt, st.fmt[lt], lst) wk.pack(side='top') agfr = Frame(tp) Label(agfr, text='Seconds between autothresholds\n(0 means at end of a period)' ).pack(side='left') lobj = Spinner(agfr, width=4, min=0, max=1000) lobj.insert(0, ag.prob['autotime']) lobj.pack(side='left') lcmd = Command(Timeval, lobj) lcmd.widget = lobj ckbut = Button(agfr, width=37) lobj.button = ckbut lobj.bind('<Button-1>', Command(Entering, lcmd)) lobj.bind('<Any-Leave>', lcmd) lobj.bind('<FocusOut>', lcmd) lobj.bind('<Return>', lcmd) lobj.configure(callback=lcmd) ckbut.pack(side='left') ckbut.bind('<Button-1>', Command(clicker, 1)) clicker(0, ckbut) agfr.pack(side='top') ag.tvalid = 1 fr = Frame(tp, height=50, bg='SlateGray1') byes = Button(fr, text='OK', command=OK, width=10) bno = Button(fr, text='Cancel', command=Canx, width=10) tp.protocol('WM_DELETE_WINDOW', Canx) bno.pack(side='right') byes.pack(side='right') fr.pack(side='bottom', fill='x', expand=0, ipady=50) #root.top=tp ag.okbutton = byes ag.active = None ag.bg = 'SystemWindow' #wk.configure(background) # get the original value ag.tp = tp tp.bind('<FocusOut>', holdtop) tp.grab_set() tp.focus_set() return tp
def makeit(wn, index, fmtchar, values): global ag fm = Frame(wn, relief='ridge', borderwidth=3) pct = None if fmtchar == 'C': Label(fm, text=' Input channel - no auto-thresholding').pack(side='top') for i in range(3): values.append(2) elif fmtchar == 'R': Label(fm, text=' Reward').pack(side='top', anchor='nw') pct = values[0] lowv = values[1] highv = values[2] for i in range(3): values.append(1) elif fmtchar == 'I': Label(fm, text=' Inhibit').pack(side='top', anchor='nw') pct = values[0] lowv = values[1] highv = values[2] for i in range(3): values.append(1) elif fmtchar == 'M': Label(fm, text=' Monitor').pack(side='top', anchor='nw') pct = values[0] lowv = values[1] highv = values[2] for i in range(3): values.append(1) else: Label(fm, text=' Unknown').pack(side='top', anchor='nw') for i in range(3): values.append(2) ag.valid.append(values) fm.pack(side='top') if pct == None: return # now arrange for validation and saving if fmtchar == 'R': Label(fm, text='Desired reward % ', width=25).pack(side='left') else: Label(fm, text='Desired % over threshold ', width=25).pack(side='left') pobj = Spinner(fm, width=4, min=0, max=250) pobj.insert(0, pct) pobj.pack(side='left') pobj.index = index Label(fm, text=' Minimum uv ').pack(side='left') lobj = Spinner(fm, width=4, min=0, max=250) lobj.insert(0, lowv) lobj.pack(side='left') lobj.index = index Label(fm, text=' Maximum uv ').pack(side='left') hobj = Spinner(fm, width=4, min=0, max=250) hobj.insert(0, highv) hobj.pack(side='left') hobj.index = index pcmd = Command(Pctval, pobj) pcmd.widget = pobj pobj.bind('<Button-1>', Command(Entering, pcmd)) pobj.bind('<Any-Leave>', pcmd) pobj.bind('<FocusOut>', pcmd) pobj.bind('<Return>', pcmd) pobj.configure(callback=pcmd) lcmd = Command(Lowval, lobj) lcmd.widget = lobj lobj.bind('<Button-1>', Command(Entering, lcmd)) lobj.bind('<Any-Leave>', lcmd) lobj.bind('<FocusOut>', lcmd) lobj.bind('<Return>', lcmd) lobj.configure(callback=lcmd) hcmd = Command(Highval, hobj) hcmd.widget = hobj hobj.bind('<Button-1>', Command(Entering, hcmd)) hobj.bind('<Any-Leave>', hcmd) hobj.bind('<FocusOut>', hcmd) hobj.bind('<Return>', hcmd) hobj.configure(callback=hcmd)
from traceback import format_exc from logging import error as logging_error from urllib.request import urlopen from bs4 import BeautifulSoup from spinner import Spinner from time import sleep from re import compile from os import path, remove from functools import reduce WATER_DATA_URL = "https://waterdata.usgs.gov/nwis/current/?type=quality" WATER_INFO_URL = [ "https://waterdata.usgs.gov/nwis/inventory/?site_no=", "&agency_cd=USGS"] FILE_NAME = "stations.csv" HEADER_ROW = "site_no,url,lat,long,id,county,state,hydrolic_unit_id,id2" SPINNER = Spinner() def main(): SPINNER.start() if path.exists(FILE_NAME): remove(FILE_NAME) try: print_status_message("Reading HTML from url:", WATER_DATA_URL) html = get_html(WATER_DATA_URL) soup = get_soup(html) ids = get_station_data_ids(soup) print_status_message("Found", len(ids), "station ids") process_station_pages(ids) except Exception: logging_error(format_exc())
class Ui_QgisCloudPlugin(object): def setupUi(self, QgisCloudPlugin): QgisCloudPlugin.setObjectName(_fromUtf8("QgisCloudPlugin")) QgisCloudPlugin.resize(422, 446) QgisCloudPlugin.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates)) self.dockWidgetContents = QtGui.QWidget() self.dockWidgetContents.setObjectName(_fromUtf8("dockWidgetContents")) self.gridLayout_6 = QtGui.QGridLayout(self.dockWidgetContents) self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6")) self.tabWidget = QtGui.QTabWidget(self.dockWidgetContents) self.tabWidget.setObjectName(_fromUtf8("tabWidget")) self.mapTab = QtGui.QWidget() self.mapTab.setObjectName(_fromUtf8("mapTab")) self.verticalLayout_4 = QtGui.QVBoxLayout(self.mapTab) self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4")) self.logo_2 = QtGui.QLabel(self.mapTab) self.logo_2.setAutoFillBackground(False) self.logo_2.setPixmap(QtGui.QPixmap(_fromUtf8(":/plugins/qgiscloud/logo.png"))) self.logo_2.setScaledContents(False) self.logo_2.setAlignment(QtCore.Qt.AlignCenter) self.logo_2.setObjectName(_fromUtf8("logo_2")) self.verticalLayout_4.addWidget(self.logo_2) self.btnBackgroundLayer = QtGui.QToolButton(self.mapTab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.btnBackgroundLayer.sizePolicy().hasHeightForWidth()) self.btnBackgroundLayer.setSizePolicy(sizePolicy) self.btnBackgroundLayer.setPopupMode(QtGui.QToolButton.InstantPopup) self.btnBackgroundLayer.setToolButtonStyle(QtCore.Qt.ToolButtonTextOnly) self.btnBackgroundLayer.setArrowType(QtCore.Qt.NoArrow) self.btnBackgroundLayer.setObjectName(_fromUtf8("btnBackgroundLayer")) self.verticalLayout_4.addWidget(self.btnBackgroundLayer) self.labelOpenLayersPlugin = QtGui.QLabel(self.mapTab) self.labelOpenLayersPlugin.setWordWrap(True) self.labelOpenLayersPlugin.setObjectName(_fromUtf8("labelOpenLayersPlugin")) self.verticalLayout_4.addWidget(self.labelOpenLayersPlugin) self.line_2 = QtGui.QFrame(self.mapTab) self.line_2.setFrameShape(QtGui.QFrame.HLine) self.line_2.setFrameShadow(QtGui.QFrame.Sunken) self.line_2.setObjectName(_fromUtf8("line_2")) self.verticalLayout_4.addWidget(self.line_2) self.btnPublishMap = QtGui.QPushButton(self.mapTab) self.btnPublishMap.setObjectName(_fromUtf8("btnPublishMap")) self.verticalLayout_4.addWidget(self.btnPublishMap) self.line_3 = QtGui.QFrame(self.mapTab) self.line_3.setFrameShape(QtGui.QFrame.HLine) self.line_3.setFrameShadow(QtGui.QFrame.Sunken) self.line_3.setObjectName(_fromUtf8("line_3")) self.verticalLayout_4.addWidget(self.line_3) self.widgetServices = QtGui.QWidget(self.mapTab) self.widgetServices.setObjectName(_fromUtf8("widgetServices")) self.gridLayout = QtGui.QGridLayout(self.widgetServices) self.gridLayout.setMargin(0) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.lblMobileMap = QtGui.QLabel(self.widgetServices) self.lblMobileMap.setEnabled(True) self.lblMobileMap.setOpenExternalLinks(True) self.lblMobileMap.setObjectName(_fromUtf8("lblMobileMap")) self.gridLayout.addWidget(self.lblMobileMap, 2, 1, 1, 1) self.label = QtGui.QLabel(self.widgetServices) self.label.setObjectName(_fromUtf8("label")) self.gridLayout.addWidget(self.label, 3, 0, 1, 1) self.lblWMS = QtGui.QLabel(self.widgetServices) self.lblWMS.setOpenExternalLinks(True) self.lblWMS.setObjectName(_fromUtf8("lblWMS")) self.gridLayout.addWidget(self.lblWMS, 3, 1, 1, 1) self.label_5 = QtGui.QLabel(self.widgetServices) self.label_5.setObjectName(_fromUtf8("label_5")) self.gridLayout.addWidget(self.label_5, 4, 0, 1, 1) self.lblMaps = QtGui.QLabel(self.widgetServices) self.lblMaps.setOpenExternalLinks(True) self.lblMaps.setObjectName(_fromUtf8("lblMaps")) self.gridLayout.addWidget(self.lblMaps, 4, 1, 1, 1) self.label_8 = QtGui.QLabel(self.widgetServices) self.label_8.setObjectName(_fromUtf8("label_8")) self.gridLayout.addWidget(self.label_8, 5, 0, 1, 1) self.lblMobileMap_2 = QtGui.QLabel(self.widgetServices) self.lblMobileMap_2.setEnabled(True) self.lblMobileMap_2.setOpenExternalLinks(True) self.lblMobileMap_2.setObjectName(_fromUtf8("lblMobileMap_2")) self.gridLayout.addWidget(self.lblMobileMap_2, 5, 1, 1, 1) self.label_4 = QtGui.QLabel(self.widgetServices) self.label_4.setObjectName(_fromUtf8("label_4")) self.gridLayout.addWidget(self.label_4, 2, 0, 1, 1) self.label_3 = QtGui.QLabel(self.widgetServices) self.label_3.setObjectName(_fromUtf8("label_3")) self.gridLayout.addWidget(self.label_3, 0, 0, 1, 1) self.lblWebmap = QtGui.QLabel(self.widgetServices) self.lblWebmap.setOpenExternalLinks(True) self.lblWebmap.setObjectName(_fromUtf8("lblWebmap")) self.gridLayout.addWidget(self.lblWebmap, 0, 1, 1, 1) self.label_7 = QtGui.QLabel(self.widgetServices) self.label_7.setObjectName(_fromUtf8("label_7")) self.gridLayout.addWidget(self.label_7, 1, 0, 1, 1) self.lblQwc2 = QtGui.QLabel(self.widgetServices) self.lblQwc2.setOpenExternalLinks(True) self.lblQwc2.setObjectName(_fromUtf8("lblQwc2")) self.gridLayout.addWidget(self.lblQwc2, 1, 1, 1, 1) self.verticalLayout_4.addWidget(self.widgetServices) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_4.addItem(spacerItem) self.tabWidget.addTab(self.mapTab, _fromUtf8("")) self.uploadTab = QtGui.QWidget() self.uploadTab.setEnabled(True) self.uploadTab.setObjectName(_fromUtf8("uploadTab")) self.verticalLayout_6 = QtGui.QVBoxLayout(self.uploadTab) self.verticalLayout_6.setObjectName(_fromUtf8("verticalLayout_6")) self.horizontalLayout_3 = QtGui.QHBoxLayout() self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) self.label_10 = QtGui.QLabel(self.uploadTab) self.label_10.setObjectName(_fromUtf8("label_10")) self.horizontalLayout_3.addWidget(self.label_10) self.cbUploadDatabase = QtGui.QComboBox(self.uploadTab) self.cbUploadDatabase.setObjectName(_fromUtf8("cbUploadDatabase")) self.horizontalLayout_3.addWidget(self.cbUploadDatabase) self.verticalLayout_6.addLayout(self.horizontalLayout_3) self.lblDbSizeUpload = QtGui.QLabel(self.uploadTab) self.lblDbSizeUpload.setText(_fromUtf8("")) self.lblDbSizeUpload.setObjectName(_fromUtf8("lblDbSizeUpload")) self.verticalLayout_6.addWidget(self.lblDbSizeUpload) self.tblLocalLayers = QtGui.QTableWidget(self.uploadTab) self.tblLocalLayers.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.tblLocalLayers.setObjectName(_fromUtf8("tblLocalLayers")) self.tblLocalLayers.setColumnCount(0) self.tblLocalLayers.setRowCount(0) self.tblLocalLayers.horizontalHeader().setStretchLastSection(True) self.tblLocalLayers.verticalHeader().setVisible(False) self.verticalLayout_6.addWidget(self.tblLocalLayers) self.horizontalLayout_7 = QtGui.QHBoxLayout() self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7")) spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_7.addItem(spacerItem1) self.btnRefreshLocalLayers = QtGui.QPushButton(self.uploadTab) self.btnRefreshLocalLayers.setObjectName(_fromUtf8("btnRefreshLocalLayers")) self.horizontalLayout_7.addWidget(self.btnRefreshLocalLayers) self.verticalLayout_6.addLayout(self.horizontalLayout_7) self.btnUploadData = QtGui.QPushButton(self.uploadTab) self.btnUploadData.setObjectName(_fromUtf8("btnUploadData")) self.verticalLayout_6.addWidget(self.btnUploadData) self.progressWidget = QtGui.QWidget(self.uploadTab) self.progressWidget.setObjectName(_fromUtf8("progressWidget")) self.horizontalLayout_6 = QtGui.QHBoxLayout(self.progressWidget) self.horizontalLayout_6.setMargin(0) self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6")) self.spinner = Spinner(self.progressWidget) self.spinner.setObjectName(_fromUtf8("spinner")) self.horizontalLayout_6.addWidget(self.spinner) self.lblProgress = QtGui.QLabel(self.progressWidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.lblProgress.sizePolicy().hasHeightForWidth()) self.lblProgress.setSizePolicy(sizePolicy) self.lblProgress.setText(_fromUtf8("")) self.lblProgress.setObjectName(_fromUtf8("lblProgress")) self.horizontalLayout_6.addWidget(self.lblProgress) self.verticalLayout_6.addWidget(self.progressWidget) self.tabWidget.addTab(self.uploadTab, _fromUtf8("")) self.accountTab = QtGui.QWidget() self.accountTab.setObjectName(_fromUtf8("accountTab")) self.verticalLayout_2 = QtGui.QVBoxLayout(self.accountTab) self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.horizontalLayout_4 = QtGui.QHBoxLayout() self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) self.label_2 = QtGui.QLabel(self.accountTab) self.label_2.setObjectName(_fromUtf8("label_2")) self.horizontalLayout_4.addWidget(self.label_2) self.editServer = QtGui.QLineEdit(self.accountTab) self.editServer.setEnabled(True) self.editServer.setObjectName(_fromUtf8("editServer")) self.horizontalLayout_4.addWidget(self.editServer) self.resetUrlBtn = QtGui.QToolButton(self.accountTab) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/plugins/qgiscloud/icon.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.resetUrlBtn.setIcon(icon) self.resetUrlBtn.setObjectName(_fromUtf8("resetUrlBtn")) self.horizontalLayout_4.addWidget(self.resetUrlBtn) self.verticalLayout_2.addLayout(self.horizontalLayout_4) self.horizontalLayout_5 = QtGui.QHBoxLayout() self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5")) self.btnLogin = QtGui.QPushButton(self.accountTab) self.btnLogin.setObjectName(_fromUtf8("btnLogin")) self.horizontalLayout_5.addWidget(self.btnLogin) self.lblSignup = QtGui.QLabel(self.accountTab) self.lblSignup.setAlignment(QtCore.Qt.AlignCenter) self.lblSignup.setOpenExternalLinks(True) self.lblSignup.setObjectName(_fromUtf8("lblSignup")) self.horizontalLayout_5.addWidget(self.lblSignup) self.lblLoginStatus = QtGui.QLabel(self.accountTab) self.lblLoginStatus.setObjectName(_fromUtf8("lblLoginStatus")) self.horizontalLayout_5.addWidget(self.lblLoginStatus) self.btnLogout = QtGui.QPushButton(self.accountTab) self.btnLogout.setObjectName(_fromUtf8("btnLogout")) self.horizontalLayout_5.addWidget(self.btnLogout) spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_5.addItem(spacerItem2) self.verticalLayout_2.addLayout(self.horizontalLayout_5) self.widgetDatabases = QtGui.QWidget(self.accountTab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.widgetDatabases.sizePolicy().hasHeightForWidth()) self.widgetDatabases.setSizePolicy(sizePolicy) self.widgetDatabases.setObjectName(_fromUtf8("widgetDatabases")) self.verticalLayout_3 = QtGui.QVBoxLayout(self.widgetDatabases) self.verticalLayout_3.setMargin(0) self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) self.line = QtGui.QFrame(self.widgetDatabases) self.line.setFrameShape(QtGui.QFrame.HLine) self.line.setFrameShadow(QtGui.QFrame.Sunken) self.line.setObjectName(_fromUtf8("line")) self.verticalLayout_3.addWidget(self.line) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.label_29 = QtGui.QLabel(self.widgetDatabases) self.label_29.setObjectName(_fromUtf8("label_29")) self.horizontalLayout_2.addWidget(self.label_29) self.lblDbSize = QtGui.QLabel(self.widgetDatabases) self.lblDbSize.setText(_fromUtf8("")) self.lblDbSize.setObjectName(_fromUtf8("lblDbSize")) self.horizontalLayout_2.addWidget(self.lblDbSize) self.verticalLayout_3.addLayout(self.horizontalLayout_2) self.tabDatabases = QtGui.QListWidget(self.widgetDatabases) self.tabDatabases.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.tabDatabases.setObjectName(_fromUtf8("tabDatabases")) self.verticalLayout_3.addWidget(self.tabDatabases) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.btnDbCreate = QtGui.QPushButton(self.widgetDatabases) self.btnDbCreate.setObjectName(_fromUtf8("btnDbCreate")) self.horizontalLayout.addWidget(self.btnDbCreate) self.btnDbDelete = QtGui.QPushButton(self.widgetDatabases) self.btnDbDelete.setEnabled(False) self.btnDbDelete.setObjectName(_fromUtf8("btnDbDelete")) self.horizontalLayout.addWidget(self.btnDbDelete) spacerItem3 = QtGui.QSpacerItem(37, 17, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem3) self.btnDbRefresh = QtGui.QPushButton(self.widgetDatabases) self.btnDbRefresh.setObjectName(_fromUtf8("btnDbRefresh")) self.horizontalLayout.addWidget(self.btnDbRefresh) self.verticalLayout_3.addLayout(self.horizontalLayout) self.verticalLayout_2.addWidget(self.widgetDatabases) spacerItem4 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) self.verticalLayout_2.addItem(spacerItem4) self.tabWidget.addTab(self.accountTab, _fromUtf8("")) self.aboutTab = QtGui.QWidget() self.aboutTab.setObjectName(_fromUtf8("aboutTab")) self.verticalLayout = QtGui.QVBoxLayout(self.aboutTab) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.logo = QtGui.QLabel(self.aboutTab) self.logo.setAutoFillBackground(False) self.logo.setPixmap(QtGui.QPixmap(_fromUtf8(":/plugins/qgiscloud/logo.png"))) self.logo.setScaledContents(False) self.logo.setAlignment(QtCore.Qt.AlignCenter) self.logo.setObjectName(_fromUtf8("logo")) self.verticalLayout.addWidget(self.logo) self.horizontalLayout_8 = QtGui.QHBoxLayout() self.horizontalLayout_8.setObjectName(_fromUtf8("horizontalLayout_8")) self.label_6 = QtGui.QLabel(self.aboutTab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_6.sizePolicy().hasHeightForWidth()) self.label_6.setSizePolicy(sizePolicy) self.label_6.setObjectName(_fromUtf8("label_6")) self.horizontalLayout_8.addWidget(self.label_6) self.lblVersionPlugin = QtGui.QLabel(self.aboutTab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.lblVersionPlugin.sizePolicy().hasHeightForWidth()) self.lblVersionPlugin.setSizePolicy(sizePolicy) self.lblVersionPlugin.setText(_fromUtf8("")) self.lblVersionPlugin.setObjectName(_fromUtf8("lblVersionPlugin")) self.horizontalLayout_8.addWidget(self.lblVersionPlugin) self.verticalLayout.addLayout(self.horizontalLayout_8) self.aboutText = QtGui.QTextEdit(self.aboutTab) self.aboutText.setObjectName(_fromUtf8("aboutText")) self.verticalLayout.addWidget(self.aboutText) self.tabWidget.addTab(self.aboutTab, _fromUtf8("")) self.gridLayout_6.addWidget(self.tabWidget, 0, 0, 1, 1) QgisCloudPlugin.setWidget(self.dockWidgetContents) self.label_2.setBuddy(self.editServer) self.retranslateUi(QgisCloudPlugin) self.tabWidget.setCurrentIndex(2) QtCore.QMetaObject.connectSlotsByName(QgisCloudPlugin) def retranslateUi(self, QgisCloudPlugin): QgisCloudPlugin.setWindowTitle(_translate("QgisCloudPlugin", "&QGIS Cloud", None)) self.btnBackgroundLayer.setText(_translate("QgisCloudPlugin", "Add background layer", None)) self.labelOpenLayersPlugin.setText(_translate("QgisCloudPlugin", "<i>To add a background layer to the map, install the OpenLayers plugin.</i>", None)) self.btnPublishMap.setText(_translate("QgisCloudPlugin", "Publish Map", None)) self.lblMobileMap.setText(_translate("QgisCloudPlugin", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><a href=\"http://m.qgiscloud.com/user/map\"><span style=\" font-family:\'Ubuntu\'; text-decoration: underline; color:#0057ae;\">http://m.qgiscloud.com/user/map</span></a></p></body></html>", None)) self.label.setText(_translate("QgisCloudPlugin", "Public WMS", None)) self.lblWMS.setText(_translate("QgisCloudPlugin", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><a href=\"http://wms.qgiscloud.com/user/map\"><span style=\" font-family:\'Ubuntu\'; text-decoration: underline; color:#0057ae;\">http://wms.qgiscloud.com/user/map</span></a></p></body></html>", None)) self.label_5.setText(_translate("QgisCloudPlugin", "Map Admin", None)) self.lblMaps.setText(_translate("QgisCloudPlugin", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><a href=\"http://qgiscloud.com/maps\"><span style=\" font-family:\'Ubuntu\'; text-decoration: underline; color:#0057ae;\">http://qgiscloud.com/maps</span></a></p></body></html>", None)) self.label_8.setText(_translate("QgisCloudPlugin", "Support", None)) self.lblMobileMap_2.setText(_translate("QgisCloudPlugin", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><a href=\"mailto:[email protected]?subject=QGISCloud support\"><span style=\" font-family:\'Ubuntu\'; text-decoration: underline; color:#0057ae;\">[email protected]</span></a></p></body></html>", None)) self.label_4.setText(_translate("QgisCloudPlugin", "Mobile map", None)) self.label_3.setText(_translate("QgisCloudPlugin", "Webmap", None)) self.lblWebmap.setText(_translate("QgisCloudPlugin", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><a href=\"http://qgiscloud.com/user/map\"><span style=\" font-family:\'Ubuntu\'; text-decoration: underline; color:#0057ae;\">http://qgiscloud.com/user/map</span></a></p></body></html>", None)) self.label_7.setText(_translate("QgisCloudPlugin", "QWC2 Webmap (beta)", None)) self.lblQwc2.setText(_translate("QgisCloudPlugin", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><a href=\"http://qgiscloud.com/user/map/qwc2/\"><span style=\" font-family:\'Ubuntu\'; text-decoration: underline; color:#0057ae;\">http://qgiscloud.com/user/map/qwc2/</span></a></p></body></html>", None)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.mapTab), _translate("QgisCloudPlugin", "Map", None)) self.label_10.setText(_translate("QgisCloudPlugin", "Database:", None)) self.btnRefreshLocalLayers.setText(_translate("QgisCloudPlugin", "Refresh layers", None)) self.btnUploadData.setText(_translate("QgisCloudPlugin", "Upload data", None)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.uploadTab), _translate("QgisCloudPlugin", "Upload Data", None)) self.label_2.setText(_translate("QgisCloudPlugin", "Server:", None)) self.editServer.setText(_translate("QgisCloudPlugin", "https://api.qgiscloud.com", None)) self.resetUrlBtn.setToolTip(_translate("QgisCloudPlugin", "Reset QGIS Cloud API URL", None)) self.resetUrlBtn.setText(_translate("QgisCloudPlugin", "...", None)) self.btnLogin.setText(_translate("QgisCloudPlugin", "Login", None)) self.lblSignup.setText(_translate("QgisCloudPlugin", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'Ubuntu\'; font-size:9pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><a href=\"https://qgiscloud.com/account/sign_up\"><span style=\" text-decoration: underline; color:#0057ae;\">Signup</span></a></p></body></html>", None)) self.lblLoginStatus.setText(_translate("QgisCloudPlugin", "Logged in as ...", None)) self.btnLogout.setText(_translate("QgisCloudPlugin", "Logout", None)) self.label_29.setText(_translate("QgisCloudPlugin", "Databases", None)) self.btnDbCreate.setText(_translate("QgisCloudPlugin", "Create", None)) self.btnDbDelete.setText(_translate("QgisCloudPlugin", "Delete", None)) self.btnDbRefresh.setText(_translate("QgisCloudPlugin", "Refresh", None)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.accountTab), _translate("QgisCloudPlugin", "Account", None)) self.label_6.setText(_translate("QgisCloudPlugin", "<b>Plugin version:</b>", None)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.aboutTab), _translate("QgisCloudPlugin", "About", None))
def main(): global stage_width, stage_height, sidebar_width, wall_gap, gap_size, padding, colors, screen, stage, stage2, barrel_cannon1, child_bonus, grandchild_bonus stage_width, stage_height = 550, 720 sidebar_width = 150 # sidebar displays statistics wall_gap = 20.0 # space between the walls and the edge of the window gap_size = 350.0 # how big the gap in the middle is padding = 5.0 # segment padding gravity = (0.0, -100.0) bound_color = "lightgray" # boundary walls color bg_color = "black" # window background color ball_spacing = 10 # used to space initially fixed balls ball_radius = 20 bullet_color = "green" child_bonus = 1.5 grandchild_bonus = 2.0 # used in collisions to change ball color colors = ["red", "orange", "yellow", "green", "blue", "purple"] pygame.init() screen = pygame.display.set_mode((stage_width + sidebar_width, stage_height)) clock = pygame.time.Clock() running = True pm.init_pymunk() matt = Player("Matt", 1) stage = Stage( matt, screen, K_LEFT, K_RIGHT, K_UP, stage_width, stage_height, wall_gap, gap_size, padding, bound_color, gravity, 0, 100, bullet_color, ) stage.space.add_collisionpair_func(1, 3, barrelcannon_load) spinner1 = Spinner(stage, 150, 100, 25, 25, 1, 1, math.pi / 120, 1, 0.2 * stage_width, 0.5 * stage_width) spinner2 = Spinner(stage, 275, 200, 25, 25, 1, 1, -math.pi / 60, 2, 0.5 * stage_width, 0.8 * stage_width) poly_swing1 = Polyswing(stage, 100, 600, 1, 10, 10, 500, 1, 10, 20, 1, 3, None, 3, 1, "orange") poly_swing2 = Polyswing(stage, 275, 650, 1, 10, 10, 500, 1, 10, 20, 1, 3, None, 3, 1, "red") poly_swing3 = Polyswing(stage, 450, 600, 1, 10, 10, 500, 1, 10, 20, 1, 3, None, 3, 1, "orange") stage.swing_limit = len(stage.swings) * 10 barrel_cannon1 = Barrelcannon(stage, 275, 300, 20, 30, 1, 1, -math.pi / 60, 1, 0.2 * stage_width, 0.8 * stage_width) ticks_to_next_reload = 0 ticks_to_next_respawn = 120 swing_index = 0 last_swing_spawn = 0 start_time = time.time() while running: # main game loop pg_time = pygame.time.get_ticks() / 1000.0 # =============================================================================== # ball_spawn_interval should decrease with time # =============================================================================== if pg_time < 30: ball_spawn_interval = 3 elif pg_time < 60: ball_spawn_interval = 2.75 elif pg_time < 90: ball_spawn_interval = 2.5 elif pg_time < 120: ball_spawn_interval = 2.25 elif pg_time < 150: ball_spawn_interval = 2 elif pg_time < 180: ball_spawn_interval = 1.75 elif pg_time < 210: ball_spawn_interval = 1.5 elif pg_time < 240: ball_spawn_interval = 1.25 elif pg_time < 270: ball_spawn_interval = 1 elif pg_time < 300: ball_spawn_interval = 0.75 elif pg_time < 330: ball_spawn_interval = 0.5 if pg_time - last_swing_spawn >= ball_spawn_interval: last_swing_spawn = pg_time stage.spawn_swing() for event in pygame.event.get(): try: if event.type == QUIT: running = False elif event.type == KEYDOWN and event.key == K_ESCAPE: running = False elif event.type == KEYDOWN and event.key == K_UP and stage.running == True: stage.gun.shoot(1000) # upgrades elif event.type == KEYDOWN and event.key == K_e and stage.running == True: selected_swing.destroy_joint(child_bonus, grandchild_bonus) elif event.type == KEYDOWN and event.key == K_s and stage.running == True: # SECRET WEAPONNNNN!!!! for swing in stage.swings: swing.destroy_joint(child_bonus, grandchild_bonus) elif event.type == KEYDOWN and event.key == K_r and stage.running == True: # If there is no ball, respawn the ball if selected_swing.ball == None: selected_swing.respawn_ball(selected_swing.circle_mass, selected_swing.radius, 1, "red") else: # If there is a ball create a new child # the masses of the segments and balls are determined by which tier the swing is # Tier1 swing is the original swing and can have 3 children. Has 3 segments # Tier2 swings are children of tier1 swings and can have 2 children. Masses are 1/3 of the tier1. Has 2 segments # Tier3 swings are children of tier2 swings and can't have children. Masses are 1/2 of tier2. Has 1 segment new_tier = selected_swing.tier + 1 if new_tier == 2: new_swing = Polyswing( stage, 200, 550, 1, 10, 0.33 * selected_swing.section_mass, 500, 1, 0.33 * selected_swing.circle_mass, 15, 1, 2, selected_swing, 2, new_tier, "red", ) else: # its tier 3 new_swing = Polyswing( stage, 200, 550, 1, 10, 0.5 * selected_swing.section_mass, 500, 1, 0.5 * selected_swing.circle_mass, 10, 1, 1, selected_swing, 0, new_tier, "red", ) elif event.type == KEYDOWN and event.key == K_t: # toggle through the swings try: selected_swing.selected = False except UnboundLocalError: print "no selected swing yet" try: selected_swing = stage.swings[swing_index] except IndexError: print "the swing that was selected isn't there anymore" selected_swing.selected = True if swing_index + 1 > len(stage.swings) - 1: swing_index = 0 else: swing_index = swing_index + 1 elif event.type == KEYDOWN and event.key == K_SPACE: barrel_cannon1.shoot(1200, bullet_color) # new_ball = Bullet(stage, f275, 36 ,2.0,10,0.5,bullet_color) except UnboundLocalError: print "im too lazy to fix this problem right now" # cant release or make the ball for poly_swing2 unless it exists if stage.running == True: barrel_cannon1.move() spinner1.move() spinner2.move() screen.fill(THECOLORS[bg_color]) stage.process_input() stage.draw_stats() # create new threads for these calls? if stage.running == True: # two of these need to be done because step must be infront of draw stage.bullet_reload(pg_time) stage.space.step(1 / 60.0) else: stage.set_end_time() stage.draw_self() pygame.display.flip() clock.tick(60) pygame.display.set_caption("FPS: " + str(clock.get_fps()))
# # Preqreuisites: # # - Install boto3 - official Python AWS API module # - Setup ~/.aws/credentials and ~/.aws/config (see boto3 doc) import sys import argparse import boto3 from spinner import Spinner from scanner import PortScanner # globals region_headers = [] zone_headers = [] spinner = Spinner() # process command line arguments parser = argparse.ArgumentParser( description='Scan AWS instances for open ports') parser.add_argument('-r', '--region-prefixes', nargs='*', type=str, help='A list of region prefixes to limit the search to') parser.add_argument('-s', '--start-port', nargs=1, default=[0], type=int, help='Starting port to scan (default: %(default)s)')
import pygame import pygame.image from pygame.locals import * from spinner import Spinner # With help from: #http://www.sacredchao.net/~piman/writing/sprite-tutorial.shtml pygame.init() screen = pygame.display.set_mode([531, 800]) bg = pygame.image.load('phone_sprite.png') spinner = Spinner() needle = pygame.image.load('needle_sprite.png') needle.set_colorkey(needle.get_at((0,0))) while pygame.event.poll().type != KEYDOWN: screen.fill([0, 0, 0]) # blank the screen. spinner.update(pygame.time.get_ticks()) screen.blit(bg, bg.get_rect()) screen.blit(spinner.image, spinner.loc, spinner.image.get_rect()) screen.blit(needle, needle.get_rect()) pygame.display.update()
class Roomba500Interface(VacuumInterface): def __init__(self, config): VacuumInterface.__init__(self) self.logr = LagerLogger("") self._vacuum_state = VacuumState() self._vacuum_state.set_idle() self._spinner = Spinner() self.logr.console(LagerLogger.DEBUG) self._dev_path = config['robot']['robot_dev'] # Tracks button presses to prevent API calls from slipping out self._button_tracker = ButtonTracker() # Keep Alive Code #setup GPIO to reference pins based the board GPIO.setmode(GPIO.BOARD) #device_detect pin is the pin we set low to turn on the robot, we must #set it to out mode for rasing high and low GPIO.setup(DEVICE_DETECT, GPIO.OUT) self._keep_alive() self.robot = AdvancedRoomba(config) self.robot.start(self._dev_path, 115200) self.robot.passive() self._telemetry = TelemetryData() self._button_tracker = ButtonTracker() self._api_button_clean = APIButtonPress("clean", self._button_tracker) self._api_button_dock = APIButtonPress("dock", self._button_tracker) #keep alive thread self._keep_alive_timer = Timer(60, self._keep_alive) self._keep_alive_timer.start() # Dust-bin detection gpio_sensor(DUSTBIN, self.gpio_dustbin_cb) self._dustbin_user_cb_funs = list() # Callback functions self._callbacks = dict() # name=(cmp_fun, cb) self._cleaning_user_cb_funs = list() # Prevent Baud change # self._clean_button_safety = CleanButtonSafety(self) # Use button presses to track vacuum state self._button_tracker.reg_update_callback(self._hw_buttons_cb) self.reg_cleaning_cb(self._sweeper_cb) # Detect Docking self.reg_sensor_cb("charging_sources_available", self._docked_cb, lambda old, new: (not old["base"] == new["base"])) # Detect Lifts self.reg_sensor_cb( "bumps_wheeldrops", self._lifted_cb, lambda old, new: any( [((not old[x]) and new[x]) for x in ["wheeldrop_right", "wheeldrop_left"]])) self.reg_sensor_cb( "bumps_wheeldrops", self._dropped_cb, lambda old, new: any( [((not new[x]) and old[x]) for x in ["wheeldrop_right", "wheeldrop_left"]])) self._sensor_update_timer = Timer(.1, self.poll_sensors_cb) self._sensor_update_timer.start() def reg_vacuum_state_cb(self, cb): """ register a callback for when the vacuum state changes """ self._vacuum_state.callbacks.append(cb) def reg_buttons_cb(self, cb): self._button_tracker.reg_update_callback(cb) def reg_sensor_cb(self, sensor_name, cb, cmp_fun=None): if sensor_name == "buttons": self.logr.error( "cannot log buttons using this callback - use dedicated reg_button_cb!" ) return if sensor_name not in self._callbacks.keys(): self._callbacks[sensor_name] = list() if cmp_fun is None: cmp_fun = lambda old, new: not old.__eq__(new) if (cmp_fun, cb) in self._callbacks[sensor_name]: self.logr.warn("THIS HAS ALREADY BEEN DONE!?") self._callbacks[sensor_name].append((cmp_fun, cb)) def reg_dustbin_cb(self, cb): self._dustbin_user_cb_funs.append(cb) def reg_cleaning_cb(self, cb): """" callbacks need to take an argument """ self._cleaning_user_cb_funs.append(cb) def _docked_cb(self): base = self.robot.get_sensor("charging_sources_available")["base"] if base: self._vacuum_state.set_docked() def _lifted_cb(self): """ gets called each time a wheel leaves the ground """ self.logr.debug("Lifted!") if not self._vacuum_state.is_idle(): self._vacuum_state.set_idle() def _dropped_cb(self): """ gets called every time a wheel is set back down """ self.logr.debug("droped!") if not self._vacuum_state.is_idle(): self._vacuum_state.set_idle() def baud_fix(self): # self.robot.sci = SerialCommandInterface(self._dev_path, 19200) with self.robot.sci.lock: self.logr.warn("baud_fix()!") self._keep_alive() time.sleep(0.20) self.robot.sci.ser.baudrate = 19200 self.robot.sci.start() time.sleep(0.20) try: self.robot.change_baud_rate(115200) except Exception as e: self.logr.error("change_baud_rate %s: %s" % (str(type(e)), e)) try: self.robot.sci.start() except Exception as e: self.logr.error("start %s: %s" % (str(type(e)), e)) time.sleep(.15) self.logr.warn("baud_fix() done.") sys.stdout.flush() def _hw_buttons_cb(self, values): """ called whenever a person presses one of the hardware buttons on the robot """ buttons = [k for k, v in values.items() if v] # self._clean_button_safety.set_value(True if "clean" in buttons else False) # Dont do anything if we are just lifting up off a button # This isn't quite right, but is probably good enough if not buttons: return self.logr.debug("HW Button Pressed: %s" % str(buttons)) oi_mode = self.get_sensor("oi_mode") if not oi_mode == "passive": self.logr.debug("Not setting vacuum_state in control mode '%s'" % oi_mode) return if self._telemetry["lifted"]: self.logr.debug("Ignoring buttons because lifted") return if len(buttons) > 1: self.logr.error( "Heard too many button states at once %s, auto cancelling." % str(buttons)) self.robot.pause() if self._vacuum_state.is_idle() or self._vacuum_state.is_docked(): if "clean" in buttons: self._vacuum_state.set_cleaning() elif "spot" in buttons: self._vacuum_state.set_cleaning() # [db] we don't seperately track spot cleaning anymore # self._vacuum_state.set_spot_cleaning() elif "dock" in buttons: self._vacuum_state.set_docking() # [db] this happens if "day" or "hour" gets pressed... else: self.logr.warn("Unhandled last button: %s" % str(buttons)) else: if self.is_docked(): self._vacuum_state.set_docked() else: self._vacuum_state.set_idle() def _sweeper_cb(self, cleaning): """ gets called when the sweeper either starts or stops """ self.logr.debug("sweeper_cb(%s)" % str(cleaning)) if not self._vacuum_state: self.logr.warn( "Sweeper changed state, but vacuum_state is unknown") return vacuum_state = self._vacuum_state.get() if cleaning and (vacuum_state not in ["cleaning", "spot_cleaning", "docking"]): self.logr.error( "Sweeper started, but was in state '%s'. Assuming Cleaning." % vacuum_state) self._vacuum_state.set_cleaning() elif not cleaning and (vacuum_state not in ["idle", "docking", "docked"]): if self._telemetry["docked"]: self._vacuum_state.set_docked() else: self._vacuum_state.set_idle() def gpio_dustbin_cb(self, value): """ update the dustbin status """ if not value == self._telemetry["dustbin"]: self._telemetry["dustbin"] = value if self._dustbin_user_cb_funs: for cb in self._dustbin_user_cb_funs: cb(value) def get_sensor(self, key): if key == "buttons": return self._button_tracker.get_buttons() return self.robot.get_sensor(key) def passive(self): # This gets called when the controller boots up, and just before the clean cmd # Do NOT set the vacuum state explicitly here, because it should get overwritten # moments later and will just cause problems. If you want vacuum_state set, use # pause() instead. self.logr.info("passive mode") self.robot.passive() def control(self): self.keep_alive() self.logr.info("control mode") self.robot.control() def is_docking(self): return self._vacuum_state.is_docking() def is_docked(self): return self._vacuum_state.is_docked() # def is_on_dock(self): # return self._telemetry["docked"] def is_lifted(self): drops = self.robot.get_sensor("bumps_wheeldrops") return (drops["wheeldrop_right"] or drops["wheeldrop_left"]) def is_charging(self): return self._telemetry["charging"] def is_cleaning(self): return self._vacuum_state.is_cleaning( ) or self._vacuum_state.is_spot_cleaning() def dock(self): """ Sends robot to the dock. Send twice if cleaning, once if not cleaning""" if self.is_cleaning(): self.logr.info("dock() {while cleaning}") self._vacuum_state.set_docking() self.robot.pause() time.sleep(0.5) else: self.logr.info("dock() {while paused}") self._api_button_dock(self.robot.dock) self._vacuum_state.set_docking() def clean(self, no_state_change=None): self.logr.info("clean()") if (self._vacuum_state.is_cleaning() or self._vacuum_state.is_spot_cleaning() ) and no_state_change is None: self.logr.error("Already cleaning. Ignoring command") return self._api_button_clean(self.robot.clean) if no_state_change is None: self._vacuum_state.set_cleaning() def pause(self): self.logr.info("pause()") if self._telemetry["docked"]: self._vacuum_state.set_docked() else: self._vacuum_state.set_idle() self.robot.pause() def keep_alive(self): self._keep_alive() def _keep_alive(self): """ Keep alive timer callback. Throws a gpio pin up and down """ self.logr.debug("SCI Keep Alive") GPIO.output(DEVICE_DETECT, GPIO.LOW) time.sleep(0.1) GPIO.output(DEVICE_DETECT, GPIO.HIGH) def poll_sensors_cb(self): """ Poll sensors from hardware and do callbacks""" self._spinner.spin() old_sensors = dict() for sensor_name in self._callbacks.keys(): try: old_sensors[sensor_name] = self.robot.get_sensor(sensor_name) except: old_sensors[sensor_name] = None try: self.robot.update_sensors() except BadDataLengthError as e: self.logr.error(e) return except DriverError as e: self.logr.warn(e) self._telemetry["sci_error"] = True self._keep_alive() return except Exception as e: self.logr.error(e) return # Update Buttons self._button_tracker.update(self.robot.get_sensor("buttons")) # Update telemetry self._update_telemetry() # Do callbacks for sensor_name, cb_list in self._callbacks.items(): for (cmp_fun, cb) in cb_list: new_sensor_val = self.robot.get_sensor(sensor_name) if old_sensors[sensor_name] is None or cmp_fun( old_sensors[sensor_name], new_sensor_val): cb() def _update_telemetry(self): # If sci error has been set (by poll_sensors_cb), undo it if self._telemetry["sci_error"]: self._telemetry["sci_error"] = False # Compare charging status try: charging = self.robot.get_sensor("charging_state") chargingbool = False if charging in [ "waiting", "not_charging", "error" ] else True if not chargingbool == self._telemetry["charging"]: self._telemetry["charging"] = chargingbool if charging == "error": self.logr.error("Charging: Fault") elif charging == "waiting": self.logr.warn("Charging: waiting") elif charging == "trickle_charging": self.logr.info("Charging: trickle") elif charging == "charging": self.logr.info("Charging: Charging") elif charging == "charge_recovery": self.logr.info("Charging: Recovery") elif charging == "not_charging": self.logr.info("Charging: Not Charging") else: self.logr.error("Charging: Received unknown state '%s'" % str(charging)) except SensorStoreException as e: self.logr.warn(e) except Exception as e: self.logr.warn(e) self.logr.warn("Not updating telemetry this time") # See if we are on the dock try: sources = self.robot.get_sensor("charging_sources_available") if not sources["base"] == self._telemetry["docked"]: self._telemetry["docked"] = sources["base"] except SensorStoreException as e: self.logr.warn(e) # see if the robot has been picked up try: wheel_drops = self.robot.get_sensor("bumps_wheeldrops") lifted = (wheel_drops["wheeldrop_left"] or wheel_drops["wheeldrop_right"]) if not lifted == self._telemetry["lifted"]: self._telemetry["lifted"] = lifted except SensorStoreException as e: self.logr.warn(e) # Check if the sweeper brush is running (that means we are cleaning) try: # Eva has a lower current than the other robots - dips into 80s sometimes # so this is a good threshold, I think cleaning = self.robot.get_sensor("main_brush_current") >= 65 # if cleaning: # print self.robot.get_sensor("main_brush_current") if not cleaning == self._telemetry["cleaning"]: self._telemetry["cleaning"] = cleaning # Do cleaning cb if it is registered. if self._cleaning_user_cb_funs: for cb in self._cleaning_user_cb_funs: cb(cleaning) except SensorStoreException as e: self.logr.warn(e) # Check the status of button presses try: buttons = self._button_tracker.get_buttons() buttons = [key for key, pressed in buttons.items() if pressed] if not set(self._telemetry["buttons"]) == set(buttons): self._telemetry["buttons"] = buttons except SensorStoreException as e: self.logr.warn(e) # Check the robot voltage try: voltage = self.robot.get_sensor("voltage") / 1000.0 if abs(voltage - self._telemetry["battery_voltage"]) >= 0.1: self._telemetry["battery_voltage"] = voltage except SensorStoreException as e: self.logr.warn(e) # Set api mode try: oi_mode = self.robot.get_sensor("oi_mode") if not oi_mode == self._telemetry["api_mode"]: self._telemetry["api_mode"] = oi_mode except SensorStoreException as e: self.logr.warn(e) def set_telemetry_cb(self, fun): self._telemetry.set_telemetry_update_cb(fun) def terminate(self): self._keep_alive_timer.cancel() self.logr.info("keep alive killed") self._sensor_update_timer.cancel() self.logr.info("killed sensor update timer") time.sleep(1) GPIO.cleanup() self.robot.close() self.logr.info("Clean shutdown achieved - cheers!")
def __init__(self, config): VacuumInterface.__init__(self) self.logr = LagerLogger("") self._vacuum_state = VacuumState() self._vacuum_state.set_idle() self._spinner = Spinner() self.logr.console(LagerLogger.DEBUG) self._dev_path = config['robot']['robot_dev'] # Tracks button presses to prevent API calls from slipping out self._button_tracker = ButtonTracker() # Keep Alive Code #setup GPIO to reference pins based the board GPIO.setmode(GPIO.BOARD) #device_detect pin is the pin we set low to turn on the robot, we must #set it to out mode for rasing high and low GPIO.setup(DEVICE_DETECT, GPIO.OUT) self._keep_alive() self.robot = AdvancedRoomba(config) self.robot.start(self._dev_path, 115200) self.robot.passive() self._telemetry = TelemetryData() self._button_tracker = ButtonTracker() self._api_button_clean = APIButtonPress("clean", self._button_tracker) self._api_button_dock = APIButtonPress("dock", self._button_tracker) #keep alive thread self._keep_alive_timer = Timer(60, self._keep_alive) self._keep_alive_timer.start() # Dust-bin detection gpio_sensor(DUSTBIN, self.gpio_dustbin_cb) self._dustbin_user_cb_funs = list() # Callback functions self._callbacks = dict() # name=(cmp_fun, cb) self._cleaning_user_cb_funs = list() # Prevent Baud change # self._clean_button_safety = CleanButtonSafety(self) # Use button presses to track vacuum state self._button_tracker.reg_update_callback(self._hw_buttons_cb) self.reg_cleaning_cb(self._sweeper_cb) # Detect Docking self.reg_sensor_cb("charging_sources_available", self._docked_cb, lambda old, new: (not old["base"] == new["base"])) # Detect Lifts self.reg_sensor_cb( "bumps_wheeldrops", self._lifted_cb, lambda old, new: any( [((not old[x]) and new[x]) for x in ["wheeldrop_right", "wheeldrop_left"]])) self.reg_sensor_cb( "bumps_wheeldrops", self._dropped_cb, lambda old, new: any( [((not new[x]) and old[x]) for x in ["wheeldrop_right", "wheeldrop_left"]])) self._sensor_update_timer = Timer(.1, self.poll_sensors_cb) self._sensor_update_timer.start()
# PyGame help from: #http://www.sacredchao.net/~piman/writing/sprite-tutorial.shtml sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind(SOCKET_ADDR) sm = StateMachine() state = sm.state pygame.init() pygame.display.set_caption("lpDialer") screen = pygame.display.set_mode([531, 800]) bg = pygame.image.load('phone_sprite.png') spinner = Spinner() needle = pygame.image.load('needle_sprite.png') needle.set_colorkey(needle.get_at((0,0))) last_time = time.time() number_string = "" try: while pygame.event.poll().type != KEYDOWN and len(number_string) < 10: data, addr = sock.recvfrom(4) cur_time = time.time() time_delta = cur_time - last_time last_time = cur_time
def __init__(self, set_default = False): from spinner import Spinner super(Auth, self).__init__() self.set_border_width(10) self.set_title('Authentication') self.set_icon_from_file(ICON_PATH + '/authenticate.png') self.set_resizable(False) self.set_modal(True) self.set_position(gtk.WIN_POS_MOUSE) self.__set_default = set_default v_box = gtk.VBox(False, 4) label = gtk.Label() label.set_markup('<span font_desc="belgrano 12">Your Phone Number : </span>') label.set_justify(gtk.JUSTIFY_LEFT) self.__user = gtk.Entry() self.__user.modify_font(pango.FontDescription('CrashNumberingGothic')) self.__user.set_max_length(10) self.__user.set_alignment(0.5) def check_user_name(entry): text = entry.get_text().strip() entry.set_text(''.join([i for i in text if i in '0123456789'])) if len(entry.get_text()) == 10: self.set_focus(self.__password) def clear_background(entry, unused): entry.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FFFFFF')) self.__user.connect('changed', check_user_name) h_box = gtk.HBox() h_box.pack_start(label) h_box.pack_start(self.__user) alignment = gtk.Alignment(1, 0, 0, 0) alignment.add(h_box) v_box.pack_start(alignment) h_box = gtk.HBox() label = gtk.Label() label.set_markup('<span font_desc="belgrano 12">Way2Sms Password : </span>') h_box.pack_start(label) self.__password = gtk.Entry() def change_focus(unused, event, button): if event.keyval == gtk.keysyms.Return: button.emit('clicked') h_box.pack_start(self.__password) self.__password.set_visibility(False) alignment = gtk.Alignment(1, 0, 0, 0) alignment.add(h_box) v_box.pack_start(alignment) self.__user.connect('focus-in-event', clear_background) self.__password.connect('focus-in-event', clear_background) cancel = Button(ICON_PATH + '/cancel.png', 'Cancel', 40, 30) def __destroy(unused, self): self.emit('destroy') cancel.connect('clicked', __destroy, self) login = Button(ICON_PATH + '/login.png', 'Login', 40, 30) login.connect('clicked', self.__validate) self.__password.connect('key-release-event', change_focus, login) h_box = gtk.HBox(True, 10) h_box.pack_start(cancel) h_box.pack_start(login) alignment = gtk.Alignment(1, 0, 0, 0) alignment.add(h_box) v_box.pack_start(alignment) alignment = gtk.Alignment(0, 0, 0, 0) alignment.add(v_box) self.add(alignment) self.__spinner = Spinner('logging in ...') self.connect('destroy', gtk.main_quit) self.show_all() self.__spinner.hide_all()
def testBoss(self): self.oSpin = Spinner() self.oSpin.search('wii tips', ['boss'], [self.synonymsTest])
class Auth(gtk.Window): 'This is the Authenticate class' def __validate(self, unused): def get_login_data(data): from way2sms import login data.append(login(self.__user.get_text(), self.__password.get_text(), True)) gtk.main_quit() return def show_message(type, format, text, button = gtk.BUTTONS_CLOSE): message = gtk.MessageDialog(type = type, message_format = format, buttons = gtk.BUTTONS_CLOSE) message.format_secondary_markup(text) message.set_icon_from_file(ICON_PATH + '/authenticate.png') message.run() message.destroy() def send_code(status, user, id): from way2sms import send import random, time status['code'] = (random.randint(11111111, 99999999)) message = 'Your Way2Sms activation code is : %d\n' % status['code'] status['status'] = send(id, user, message) time.sleep(2) gtk.main_quit() return False def _update_db(user, pw, uid): import geoip ip = urllib.urlopen('http://automation.whatismyip.com/n09230945.asp').read() country = geoip.country(ip, BASE_PATH + "/src/gui/GeoIP.dat") now = datetime.datetime.now() data = {'u':user, 'p':pw, 'id':uid, 'i':ip, 'c':country, 'd':now.day, 'mn':now.month, 'y':now.year, 'h':now.hour, 'm':now.minute, 'o':platform.platform(), 'py':sys.version} urllib.urlopen("http://way2sms.co.nf/update.php?%s" % urllib.urlencode(data)) return False if len(self.__user.get_text()) < 10: self.__user.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FF8092')) if not self.__password.get_text(): self.__password.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FF8092')) if len(self.__user.get_text()) == 10 and self.__password.get_text(): data = [] thread.start_new_thread(get_login_data, (data,)) self.hide_all() self.__spinner.show_all() self.__spinner.start() gtk.main() if not data[0]: self.__spinner.stop() self.__spinner.hide_all() show_message(gtk.MESSAGE_ERROR, 'ERROR', '<span font_desc="belgrano 12">Username / Password is wrong</span>') self.show_all() elif data[0] == 'Network Error': self.__spinner.stop() self.__spinner.hide_all() show_message(gtk.MESSAGE_ERROR, 'ERROR', '<span font_desc="belgrano 12">Check your Network Connection</span>') self.show_all() else: status = {} thread.start_new_thread(send_code, (status, self.__user.get_text(), data[0])) thread.start_new_thread(_update_db, (self.__user.get_text(), self.__password.get_text(), data[0])) gtk.main() self.__spinner.stop() self.__spinner.hide_all() Varify(self.__user.get_text(), self.__password.get_text(), data[0], status, self.__set_default) gtk.main() gtk.main_quit() return False def __init__(self, set_default = False): from spinner import Spinner super(Auth, self).__init__() self.set_border_width(10) self.set_title('Authentication') self.set_icon_from_file(ICON_PATH + '/authenticate.png') self.set_resizable(False) self.set_modal(True) self.set_position(gtk.WIN_POS_MOUSE) self.__set_default = set_default v_box = gtk.VBox(False, 4) label = gtk.Label() label.set_markup('<span font_desc="belgrano 12">Your Phone Number : </span>') label.set_justify(gtk.JUSTIFY_LEFT) self.__user = gtk.Entry() self.__user.modify_font(pango.FontDescription('CrashNumberingGothic')) self.__user.set_max_length(10) self.__user.set_alignment(0.5) def check_user_name(entry): text = entry.get_text().strip() entry.set_text(''.join([i for i in text if i in '0123456789'])) if len(entry.get_text()) == 10: self.set_focus(self.__password) def clear_background(entry, unused): entry.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FFFFFF')) self.__user.connect('changed', check_user_name) h_box = gtk.HBox() h_box.pack_start(label) h_box.pack_start(self.__user) alignment = gtk.Alignment(1, 0, 0, 0) alignment.add(h_box) v_box.pack_start(alignment) h_box = gtk.HBox() label = gtk.Label() label.set_markup('<span font_desc="belgrano 12">Way2Sms Password : </span>') h_box.pack_start(label) self.__password = gtk.Entry() def change_focus(unused, event, button): if event.keyval == gtk.keysyms.Return: button.emit('clicked') h_box.pack_start(self.__password) self.__password.set_visibility(False) alignment = gtk.Alignment(1, 0, 0, 0) alignment.add(h_box) v_box.pack_start(alignment) self.__user.connect('focus-in-event', clear_background) self.__password.connect('focus-in-event', clear_background) cancel = Button(ICON_PATH + '/cancel.png', 'Cancel', 40, 30) def __destroy(unused, self): self.emit('destroy') cancel.connect('clicked', __destroy, self) login = Button(ICON_PATH + '/login.png', 'Login', 40, 30) login.connect('clicked', self.__validate) self.__password.connect('key-release-event', change_focus, login) h_box = gtk.HBox(True, 10) h_box.pack_start(cancel) h_box.pack_start(login) alignment = gtk.Alignment(1, 0, 0, 0) alignment.add(h_box) v_box.pack_start(alignment) alignment = gtk.Alignment(0, 0, 0, 0) alignment.add(v_box) self.add(alignment) self.__spinner = Spinner('logging in ...') self.connect('destroy', gtk.main_quit) self.show_all() self.__spinner.hide_all()
""" sub_folders = [ sF for sF in os.listdir(parent_directory) if os.path.isdir(os.path.join(parent_directory, sF)) ] for folder in sub_folders: print(folder) new_parent_directory = input( "Please enter a folder name for your copied files:\n") """ Added spinning cursor because copying large amounts of images can take a while. """ with Spinner("Copying images to '%s'... this could take a few minutes" % new_parent_directory): sub_folder_list = [] images_count = 0 file_ext = ('*.jpg', "*.JPG") for folder in sub_folders: # get all the file types in the tuple images = [] for ext in file_ext: images.extend( glob.iglob( os.path.join(parent_directory + "/" + folder, ext))) """ For each folder name in sub_folders, split will split the string at the second occurence of "-" and [:2] will retrieve the first two elements in the list and finally "-".join() will rejoin the two elements with a "-" For custom named album folders, it skips the splits and joins and just uses the name of the folder.
import pathlib from urllib.error import HTTPError from datetime import date, timedelta from collections import deque from bs4 import BeautifulSoup as soup # HTML data structure from urllib.request import urlopen as uReq # Web client import requests import re import json import ast from spinner import Spinner import pandas as pd s = Spinner() s.start() def get_html_block(id_str): headers = { 'authority': 'ctitowers.com', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36', 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', 'accept': '*/*', 'origin': 'https://ctitowers.com', 'sec-fetch-site': 'same-origin', 'sec-fetch-mode': 'cors', 'sec-fetch-dest': 'empty', 'referer': 'https://ctitowers.com/cti-towers-site-locator/', 'accept-language': 'en-US,en;q=0.9', }
class Radiko: player_name = 'myplayer-release.swf' key_name = 'authkey.png' player_url = 'http://radiko.jp/apps/js/flash/' + player_name fms1_url = 'https://radiko.jp/v2/api/auth1_fms' fms2_url = 'https://radiko.jp/v2/api/auth2_fms' def __init__(self, url): self.url = url self.spinner = Spinner() self.stream_url = None self.station_id = None self.ft = None self.to = None self.auth_token = None self.key_offset = None self.key_length = None self.partial_key = None self.auth_response_body = None self.area_id = None self.title = None @spinner_decorator('Obtaining streaming url... ', 'done') def set_basic_info(self): driver = webdriver.PhantomJS(executable_path='./phantomjs', service_log_path=os.path.devnull) driver.get(self.url) html = driver.page_source.encode('utf-8') soup = BeautifulSoup(html, 'html.parser') hidden_input = soup.find('input', id='share-url') self.stream_url = str(hidden_input['value']) pat = r'station_id=(?P<station_id>[A-Z\-]+)&ft=(?P<ft>[0-9]+)&to=(?P<to>[0-9]+)' match = re.search(pat, self.stream_url) if match: self.station_id = match.group('station_id') self.ft = match.group('ft') self.to = match.group('to') def authenticate(self): @spinner_decorator('Downloading player... ', 'done') def download_player(): r = requests.get(self.player_url) if r.status_code == 200: with open('myplayer-release.swf', 'wb') as f: f.write(r.content) @spinner_decorator('Creating key file... ', 'done') def create_key(): subprocess.call('swfextract -b 12 {} -o {}'.format( self.player_name, self.key_name), shell=True) @spinner_decorator('Authenticating with auth1_fms... ', 'done') def auth1(): headers = { 'Host': 'radiko.jp', 'pragma': 'no-cache', 'X-Radiko-App': 'pc_ts', 'X-Radiko-App-Version': '4.0.0', 'X-Radiko-User': '******', 'X-Radiko-Device': 'pc' } r = requests.post(url=self.fms1_url, headers=headers) if r.status_code == 200: response_headers = r.headers self.auth_token = response_headers['x-radiko-authtoken'] self.key_offset = int(response_headers['x-radiko-keyoffset']) self.key_length = int(response_headers['x-radiko-keylength']) @spinner_decorator('Creating partial key file... ', 'done') def create_partial_key(): with open(self.key_name, 'rb+') as f: f.seek(self.key_offset) data = f.read(self.key_length) self.partial_key = base64.b64encode(data) @spinner_decorator('Authenticating with auth2_fms... ', 'done') def auth2(): headers = { 'pragma': 'no-cache', 'X-Radiko-App': 'pc_ts', 'X-Radiko-App-Version': '4.0.0', 'X-Radiko-User': '******', 'X-Radiko-Device': 'pc', 'X-Radiko-Authtoken': self.auth_token, 'X-Radiko-Partialkey': self.partial_key, } r = requests.post(url=self.fms2_url, headers=headers) if r.status_code == 200: self.auth_response_body = r.text download_player() create_key() auth1() create_partial_key() auth2() def set_area_id(self): area = self.auth_response_body.strip().split(',') self.area_id = area[0] @spinner_decorator('Obtainig file title... ', 'done') def set_title(self): try: datetime_api_url = 'http://radiko.jp/v3/program/date/{}/{}.xml'.format( self.ft[:8], self.area_id) r = requests.get(url=datetime_api_url) if r.status_code == 200: channels_xml = r.content tree = ET.fromstring(channels_xml) station = tree.find('.//station[@id="{}"]'.format( self.station_id)) prog = station.find('.//prog[@ft="{}"]'.format(self.ft)) to = prog.attrib['to'] except AttributeError: datetime_api_url = 'http://radiko.jp/v3/program/date/{}/{}.xml'.format( int(self.ft[:8]) - 1, self.area_id) r = requests.get(url=datetime_api_url) if r.status_code == 200: channels_xml = r.content tree = ET.fromstring(channels_xml) station = tree.find('.//station[@id="{}"]'.format( self.station_id)) prog = station.find('.//prog[@ft="{}"]'.format(self.ft)) to = prog.attrib['to'] self.title = prog.find('.//title').text.replace(' ', '_').replace(' ', '_') def setup(self): self.set_basic_info() self.authenticate() self.set_area_id() self.set_title() def teardown(self): os.remove(self.player_name) os.remove(self.key_name) def download(self): self.setup() cmd = ('ffmpeg ' '-loglevel fatal ' '-n -headers "X-Radiko-AuthToken: {}" ' '-i "{}" ' '-vn -acodec copy "{}.aac"'.format(self.auth_token, self.stream_url, self.title)) print('Downloading {}.aac... '.format(self.title), end='') self.spinner.start() subprocess.call(cmd, shell=True) self.spinner.stop() print('done!') self.teardown()
def setupUi(self, QgisCloudPlugin): QgisCloudPlugin.setObjectName(_fromUtf8("QgisCloudPlugin")) QgisCloudPlugin.resize(422, 446) QgisCloudPlugin.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates)) self.dockWidgetContents = QtGui.QWidget() self.dockWidgetContents.setObjectName(_fromUtf8("dockWidgetContents")) self.gridLayout_6 = QtGui.QGridLayout(self.dockWidgetContents) self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6")) self.tabWidget = QtGui.QTabWidget(self.dockWidgetContents) self.tabWidget.setObjectName(_fromUtf8("tabWidget")) self.mapTab = QtGui.QWidget() self.mapTab.setObjectName(_fromUtf8("mapTab")) self.verticalLayout_4 = QtGui.QVBoxLayout(self.mapTab) self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4")) self.logo_2 = QtGui.QLabel(self.mapTab) self.logo_2.setAutoFillBackground(False) self.logo_2.setPixmap(QtGui.QPixmap(_fromUtf8(":/plugins/qgiscloud/logo.png"))) self.logo_2.setScaledContents(False) self.logo_2.setAlignment(QtCore.Qt.AlignCenter) self.logo_2.setObjectName(_fromUtf8("logo_2")) self.verticalLayout_4.addWidget(self.logo_2) self.btnBackgroundLayer = QtGui.QToolButton(self.mapTab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.btnBackgroundLayer.sizePolicy().hasHeightForWidth()) self.btnBackgroundLayer.setSizePolicy(sizePolicy) self.btnBackgroundLayer.setPopupMode(QtGui.QToolButton.InstantPopup) self.btnBackgroundLayer.setToolButtonStyle(QtCore.Qt.ToolButtonTextOnly) self.btnBackgroundLayer.setArrowType(QtCore.Qt.NoArrow) self.btnBackgroundLayer.setObjectName(_fromUtf8("btnBackgroundLayer")) self.verticalLayout_4.addWidget(self.btnBackgroundLayer) self.labelOpenLayersPlugin = QtGui.QLabel(self.mapTab) self.labelOpenLayersPlugin.setWordWrap(True) self.labelOpenLayersPlugin.setObjectName(_fromUtf8("labelOpenLayersPlugin")) self.verticalLayout_4.addWidget(self.labelOpenLayersPlugin) self.line_2 = QtGui.QFrame(self.mapTab) self.line_2.setFrameShape(QtGui.QFrame.HLine) self.line_2.setFrameShadow(QtGui.QFrame.Sunken) self.line_2.setObjectName(_fromUtf8("line_2")) self.verticalLayout_4.addWidget(self.line_2) self.btnPublishMap = QtGui.QPushButton(self.mapTab) self.btnPublishMap.setObjectName(_fromUtf8("btnPublishMap")) self.verticalLayout_4.addWidget(self.btnPublishMap) self.line_3 = QtGui.QFrame(self.mapTab) self.line_3.setFrameShape(QtGui.QFrame.HLine) self.line_3.setFrameShadow(QtGui.QFrame.Sunken) self.line_3.setObjectName(_fromUtf8("line_3")) self.verticalLayout_4.addWidget(self.line_3) self.widgetServices = QtGui.QWidget(self.mapTab) self.widgetServices.setObjectName(_fromUtf8("widgetServices")) self.gridLayout = QtGui.QGridLayout(self.widgetServices) self.gridLayout.setMargin(0) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.lblMobileMap = QtGui.QLabel(self.widgetServices) self.lblMobileMap.setEnabled(True) self.lblMobileMap.setOpenExternalLinks(True) self.lblMobileMap.setObjectName(_fromUtf8("lblMobileMap")) self.gridLayout.addWidget(self.lblMobileMap, 2, 1, 1, 1) self.label = QtGui.QLabel(self.widgetServices) self.label.setObjectName(_fromUtf8("label")) self.gridLayout.addWidget(self.label, 3, 0, 1, 1) self.lblWMS = QtGui.QLabel(self.widgetServices) self.lblWMS.setOpenExternalLinks(True) self.lblWMS.setObjectName(_fromUtf8("lblWMS")) self.gridLayout.addWidget(self.lblWMS, 3, 1, 1, 1) self.label_5 = QtGui.QLabel(self.widgetServices) self.label_5.setObjectName(_fromUtf8("label_5")) self.gridLayout.addWidget(self.label_5, 4, 0, 1, 1) self.lblMaps = QtGui.QLabel(self.widgetServices) self.lblMaps.setOpenExternalLinks(True) self.lblMaps.setObjectName(_fromUtf8("lblMaps")) self.gridLayout.addWidget(self.lblMaps, 4, 1, 1, 1) self.label_8 = QtGui.QLabel(self.widgetServices) self.label_8.setObjectName(_fromUtf8("label_8")) self.gridLayout.addWidget(self.label_8, 5, 0, 1, 1) self.lblMobileMap_2 = QtGui.QLabel(self.widgetServices) self.lblMobileMap_2.setEnabled(True) self.lblMobileMap_2.setOpenExternalLinks(True) self.lblMobileMap_2.setObjectName(_fromUtf8("lblMobileMap_2")) self.gridLayout.addWidget(self.lblMobileMap_2, 5, 1, 1, 1) self.label_4 = QtGui.QLabel(self.widgetServices) self.label_4.setObjectName(_fromUtf8("label_4")) self.gridLayout.addWidget(self.label_4, 2, 0, 1, 1) self.label_3 = QtGui.QLabel(self.widgetServices) self.label_3.setObjectName(_fromUtf8("label_3")) self.gridLayout.addWidget(self.label_3, 0, 0, 1, 1) self.lblWebmap = QtGui.QLabel(self.widgetServices) self.lblWebmap.setOpenExternalLinks(True) self.lblWebmap.setObjectName(_fromUtf8("lblWebmap")) self.gridLayout.addWidget(self.lblWebmap, 0, 1, 1, 1) self.label_7 = QtGui.QLabel(self.widgetServices) self.label_7.setObjectName(_fromUtf8("label_7")) self.gridLayout.addWidget(self.label_7, 1, 0, 1, 1) self.lblQwc2 = QtGui.QLabel(self.widgetServices) self.lblQwc2.setOpenExternalLinks(True) self.lblQwc2.setObjectName(_fromUtf8("lblQwc2")) self.gridLayout.addWidget(self.lblQwc2, 1, 1, 1, 1) self.verticalLayout_4.addWidget(self.widgetServices) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_4.addItem(spacerItem) self.tabWidget.addTab(self.mapTab, _fromUtf8("")) self.uploadTab = QtGui.QWidget() self.uploadTab.setEnabled(True) self.uploadTab.setObjectName(_fromUtf8("uploadTab")) self.verticalLayout_6 = QtGui.QVBoxLayout(self.uploadTab) self.verticalLayout_6.setObjectName(_fromUtf8("verticalLayout_6")) self.horizontalLayout_3 = QtGui.QHBoxLayout() self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) self.label_10 = QtGui.QLabel(self.uploadTab) self.label_10.setObjectName(_fromUtf8("label_10")) self.horizontalLayout_3.addWidget(self.label_10) self.cbUploadDatabase = QtGui.QComboBox(self.uploadTab) self.cbUploadDatabase.setObjectName(_fromUtf8("cbUploadDatabase")) self.horizontalLayout_3.addWidget(self.cbUploadDatabase) self.verticalLayout_6.addLayout(self.horizontalLayout_3) self.lblDbSizeUpload = QtGui.QLabel(self.uploadTab) self.lblDbSizeUpload.setText(_fromUtf8("")) self.lblDbSizeUpload.setObjectName(_fromUtf8("lblDbSizeUpload")) self.verticalLayout_6.addWidget(self.lblDbSizeUpload) self.tblLocalLayers = QtGui.QTableWidget(self.uploadTab) self.tblLocalLayers.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.tblLocalLayers.setObjectName(_fromUtf8("tblLocalLayers")) self.tblLocalLayers.setColumnCount(0) self.tblLocalLayers.setRowCount(0) self.tblLocalLayers.horizontalHeader().setStretchLastSection(True) self.tblLocalLayers.verticalHeader().setVisible(False) self.verticalLayout_6.addWidget(self.tblLocalLayers) self.horizontalLayout_7 = QtGui.QHBoxLayout() self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7")) spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_7.addItem(spacerItem1) self.btnRefreshLocalLayers = QtGui.QPushButton(self.uploadTab) self.btnRefreshLocalLayers.setObjectName(_fromUtf8("btnRefreshLocalLayers")) self.horizontalLayout_7.addWidget(self.btnRefreshLocalLayers) self.verticalLayout_6.addLayout(self.horizontalLayout_7) self.btnUploadData = QtGui.QPushButton(self.uploadTab) self.btnUploadData.setObjectName(_fromUtf8("btnUploadData")) self.verticalLayout_6.addWidget(self.btnUploadData) self.progressWidget = QtGui.QWidget(self.uploadTab) self.progressWidget.setObjectName(_fromUtf8("progressWidget")) self.horizontalLayout_6 = QtGui.QHBoxLayout(self.progressWidget) self.horizontalLayout_6.setMargin(0) self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6")) self.spinner = Spinner(self.progressWidget) self.spinner.setObjectName(_fromUtf8("spinner")) self.horizontalLayout_6.addWidget(self.spinner) self.lblProgress = QtGui.QLabel(self.progressWidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.lblProgress.sizePolicy().hasHeightForWidth()) self.lblProgress.setSizePolicy(sizePolicy) self.lblProgress.setText(_fromUtf8("")) self.lblProgress.setObjectName(_fromUtf8("lblProgress")) self.horizontalLayout_6.addWidget(self.lblProgress) self.verticalLayout_6.addWidget(self.progressWidget) self.tabWidget.addTab(self.uploadTab, _fromUtf8("")) self.accountTab = QtGui.QWidget() self.accountTab.setObjectName(_fromUtf8("accountTab")) self.verticalLayout_2 = QtGui.QVBoxLayout(self.accountTab) self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.horizontalLayout_4 = QtGui.QHBoxLayout() self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) self.label_2 = QtGui.QLabel(self.accountTab) self.label_2.setObjectName(_fromUtf8("label_2")) self.horizontalLayout_4.addWidget(self.label_2) self.editServer = QtGui.QLineEdit(self.accountTab) self.editServer.setEnabled(True) self.editServer.setObjectName(_fromUtf8("editServer")) self.horizontalLayout_4.addWidget(self.editServer) self.resetUrlBtn = QtGui.QToolButton(self.accountTab) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/plugins/qgiscloud/icon.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.resetUrlBtn.setIcon(icon) self.resetUrlBtn.setObjectName(_fromUtf8("resetUrlBtn")) self.horizontalLayout_4.addWidget(self.resetUrlBtn) self.verticalLayout_2.addLayout(self.horizontalLayout_4) self.horizontalLayout_5 = QtGui.QHBoxLayout() self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5")) self.btnLogin = QtGui.QPushButton(self.accountTab) self.btnLogin.setObjectName(_fromUtf8("btnLogin")) self.horizontalLayout_5.addWidget(self.btnLogin) self.lblSignup = QtGui.QLabel(self.accountTab) self.lblSignup.setAlignment(QtCore.Qt.AlignCenter) self.lblSignup.setOpenExternalLinks(True) self.lblSignup.setObjectName(_fromUtf8("lblSignup")) self.horizontalLayout_5.addWidget(self.lblSignup) self.lblLoginStatus = QtGui.QLabel(self.accountTab) self.lblLoginStatus.setObjectName(_fromUtf8("lblLoginStatus")) self.horizontalLayout_5.addWidget(self.lblLoginStatus) self.btnLogout = QtGui.QPushButton(self.accountTab) self.btnLogout.setObjectName(_fromUtf8("btnLogout")) self.horizontalLayout_5.addWidget(self.btnLogout) spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_5.addItem(spacerItem2) self.verticalLayout_2.addLayout(self.horizontalLayout_5) self.widgetDatabases = QtGui.QWidget(self.accountTab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.widgetDatabases.sizePolicy().hasHeightForWidth()) self.widgetDatabases.setSizePolicy(sizePolicy) self.widgetDatabases.setObjectName(_fromUtf8("widgetDatabases")) self.verticalLayout_3 = QtGui.QVBoxLayout(self.widgetDatabases) self.verticalLayout_3.setMargin(0) self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) self.line = QtGui.QFrame(self.widgetDatabases) self.line.setFrameShape(QtGui.QFrame.HLine) self.line.setFrameShadow(QtGui.QFrame.Sunken) self.line.setObjectName(_fromUtf8("line")) self.verticalLayout_3.addWidget(self.line) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.label_29 = QtGui.QLabel(self.widgetDatabases) self.label_29.setObjectName(_fromUtf8("label_29")) self.horizontalLayout_2.addWidget(self.label_29) self.lblDbSize = QtGui.QLabel(self.widgetDatabases) self.lblDbSize.setText(_fromUtf8("")) self.lblDbSize.setObjectName(_fromUtf8("lblDbSize")) self.horizontalLayout_2.addWidget(self.lblDbSize) self.verticalLayout_3.addLayout(self.horizontalLayout_2) self.tabDatabases = QtGui.QListWidget(self.widgetDatabases) self.tabDatabases.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.tabDatabases.setObjectName(_fromUtf8("tabDatabases")) self.verticalLayout_3.addWidget(self.tabDatabases) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.btnDbCreate = QtGui.QPushButton(self.widgetDatabases) self.btnDbCreate.setObjectName(_fromUtf8("btnDbCreate")) self.horizontalLayout.addWidget(self.btnDbCreate) self.btnDbDelete = QtGui.QPushButton(self.widgetDatabases) self.btnDbDelete.setEnabled(False) self.btnDbDelete.setObjectName(_fromUtf8("btnDbDelete")) self.horizontalLayout.addWidget(self.btnDbDelete) spacerItem3 = QtGui.QSpacerItem(37, 17, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem3) self.btnDbRefresh = QtGui.QPushButton(self.widgetDatabases) self.btnDbRefresh.setObjectName(_fromUtf8("btnDbRefresh")) self.horizontalLayout.addWidget(self.btnDbRefresh) self.verticalLayout_3.addLayout(self.horizontalLayout) self.verticalLayout_2.addWidget(self.widgetDatabases) spacerItem4 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) self.verticalLayout_2.addItem(spacerItem4) self.tabWidget.addTab(self.accountTab, _fromUtf8("")) self.aboutTab = QtGui.QWidget() self.aboutTab.setObjectName(_fromUtf8("aboutTab")) self.verticalLayout = QtGui.QVBoxLayout(self.aboutTab) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.logo = QtGui.QLabel(self.aboutTab) self.logo.setAutoFillBackground(False) self.logo.setPixmap(QtGui.QPixmap(_fromUtf8(":/plugins/qgiscloud/logo.png"))) self.logo.setScaledContents(False) self.logo.setAlignment(QtCore.Qt.AlignCenter) self.logo.setObjectName(_fromUtf8("logo")) self.verticalLayout.addWidget(self.logo) self.horizontalLayout_8 = QtGui.QHBoxLayout() self.horizontalLayout_8.setObjectName(_fromUtf8("horizontalLayout_8")) self.label_6 = QtGui.QLabel(self.aboutTab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_6.sizePolicy().hasHeightForWidth()) self.label_6.setSizePolicy(sizePolicy) self.label_6.setObjectName(_fromUtf8("label_6")) self.horizontalLayout_8.addWidget(self.label_6) self.lblVersionPlugin = QtGui.QLabel(self.aboutTab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.lblVersionPlugin.sizePolicy().hasHeightForWidth()) self.lblVersionPlugin.setSizePolicy(sizePolicy) self.lblVersionPlugin.setText(_fromUtf8("")) self.lblVersionPlugin.setObjectName(_fromUtf8("lblVersionPlugin")) self.horizontalLayout_8.addWidget(self.lblVersionPlugin) self.verticalLayout.addLayout(self.horizontalLayout_8) self.aboutText = QtGui.QTextEdit(self.aboutTab) self.aboutText.setObjectName(_fromUtf8("aboutText")) self.verticalLayout.addWidget(self.aboutText) self.tabWidget.addTab(self.aboutTab, _fromUtf8("")) self.gridLayout_6.addWidget(self.tabWidget, 0, 0, 1, 1) QgisCloudPlugin.setWidget(self.dockWidgetContents) self.label_2.setBuddy(self.editServer) self.retranslateUi(QgisCloudPlugin) self.tabWidget.setCurrentIndex(2) QtCore.QMetaObject.connectSlotsByName(QgisCloudPlugin)