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
示例#2
0
文件: put.py 项目: alrouen/gridfscmd
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)
示例#3
0
    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")
示例#4
0
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)
示例#5
0
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"))
示例#6
0
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 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)
示例#8
0
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")
示例#9
0
    def _remote_go(self, delay, url_timeout, search_max, download_file_limit):
        self.logger.info("Starting remote search...")

        for filetype in self.file_types:
            self.files = [
            ]  # Stores URLs with files, clear out for each filetype.

            print_string = "Searching online for '{}' files in {}...".format(
                filetype, self.domain)
            stop_spinner = threading.Event()
            spin_thread = Spinner(stop_spinner,
                                  prefix="[*] Info: {}".format(print_string))
            spin_thread.start()

            self.files = self._get_docs_by_filetype(filetype, search_max)

            stop_spinner.set()
            spin_thread.join()
            self.logger.success(print_string + "DONE")

            if self.stealth:
                # If stealth just display collected files.
                self.logger.info("Results: {0} {1} files found".format(
                    len(self.files), filetype))
                for file_name in self.files:
                    print("  * " + file_name)
            else:
                # Otherwise download and analyze them
                print_string = "Downloading and analyzing files..."
                stop_spinner = threading.Event()
                spin_thread = Spinner(
                    stop_spinner, prefix="[*] Info: {}".format(print_string))
                spin_thread.start()

                # If it's not stealth mode download and analyze files
                if len(self.files) > download_file_limit:
                    self.files = self.files[:download_file_limit + 1]
                [self.input_queue.put(url) for url in self.files]

                stop_spinner.set()
                spin_thread.join()
                self.logger.success(print_string + "DONE")

        self._finish_work()
示例#10
0
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))
示例#11
0
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"))
示例#12
0
    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
示例#13
0
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
示例#14
0
    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
示例#15
0
    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
示例#16
0
文件: rm.py 项目: alrouen/gridfscmd
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."
示例#17
0
    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
示例#18
0
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)
示例#19
0
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
示例#20
0
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."
示例#21
0
    """
    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.
示例#22
0
#
# 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)')
示例#23
0
    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)
示例#24
0
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
示例#25
0
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)
示例#26
0
def makescreen(root):
    dlg = Pmw.Dialog(master=root,
                     buttons=('OK', 'Cancel'),
                     title='Zcomposite control settings')

    tp = dlg.component('hull')
    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)

    try:
        if root.freezer:
            tp.bind('<Configure>', Command(_freeze_window, tp, sizer))
    except:
        pass

    wk = Frame(dlg.interior())
    Label(wk,
          text='Zcomposite settings for set %d' % zcd['set']).pack(side=TOP,
                                                                   expand=1,
                                                                   fill='x',
                                                                   padx=20,
                                                                   pady=20)
    wk.pack(side=TOP, expand=1, fill=BOTH)

    fr1 = Frame(dlg.interior(), relief='ridge', borderwidth=3)
    ben = RBbox(fr1,
                'Enable/disable status of set',
                buts=disen,
                current=disen[zcd['enab']])

    extra = 'Ampl Asymmetry, Coherence, Phase use AB,AC,AD,BC,BD,CD\nAbs Pwr, Rel Pwr, Pwr Ratio use A,B,C,D'
    fr2 = Frame(dlg.interior(), relief='ridge', borderwidth=3)
    bpar = RBbox(fr2,
                 'Parameters to consider',
                 buts=zscparnames,
                 current=zcd['par'],
                 extra=extra,
                 cbox=(1, 3, 3))

    fr3 = Frame(dlg.interior(), relief='ridge', borderwidth=3)
    bchan = RBbox(fr3,
                  'Channels to consider',
                  buts=zscchancodes,
                  current=zcd['chan'],
                  cbox=(1, 4, 10))

    fr4 = Frame(dlg.interior(), relief='ridge', borderwidth=3)
    # bands

    bextra = 'FREQ means all frequency bands   PR means all Pwr Ratios\nDelta=1-4  Theta=4-8  Alpha=8-12  Beta=12-25  High Beta=25-30\nB1=12-15  B2=15-18  B3=18-25  A1=8-10  A2=10-12'
    bband = RBbox(fr4,
                  'Bands to consider',
                  buts=zscbandcodes,
                  current=zcd['band'],
                  extra=bextra,
                  cbox=(3, 10, 10))

    fr5 = Frame(dlg.interior(), relief='ridge', borderwidth=3)
    Label(fr5, text='Threshold values to be below').grid(row=0,
                                                         column=0,
                                                         columnspan=5,
                                                         sticky='ew')
    sthrsh = Spinner(fr5,
                     width=4,
                     min=0,
                     max=10.0,
                     increment=0.1,
                     value=zcd['thrsh'])
    sthrsh.grid(row=0, column=7)
    fr5.pack(side=TOP, fill=BOTH, expand=1)

    fr6 = Frame(dlg.interior(), relief='ridge', borderwidth=3)
    Label(fr6,
          text='Percent values below thresholds for "Rewardable" state').grid(
              row=0, column=0, columnspan=5, sticky='ew')
    spct = Spinner(fr6,
                   width=4,
                   min=0,
                   max=100,
                   increment=1,
                   value=zcd['percent'])
    spct.grid(row=0, column=7)
    fr6.pack(side=TOP, fill=BOTH, expand=1)

    zcd['ben'] = ben
    zcd['bpar'] = bpar
    zcd['bchan'] = bchan
    zcd['bband'] = bband
    zcd['sthrsh'] = (sthrsh, 2)
    zcd['spct'] = (spct, 2)
    return dlg
示例#27
0
    print("train accuracy: {} %".format(100 - np.mean(np.abs(Y_prediction_train - Y_train)) * 100))
    print("test accuracy: {} %".format(100 - np.mean(np.abs(Y_prediction_test - Y_test)) * 100))

    
    d = {"costs": costs,
         "Y_prediction_test": Y_prediction_test, 
         "Y_prediction_train" : Y_prediction_train, 
         "w" : w, 
         "b" : b,
         "learning_rate" : learning_rate,
         "num_iterations": num_iterations}
    
    return d

print("Training model.........................")
with Spinner():
    d = model(train_set_x, train_set_y, test_set_x, test_set_y, num_iterations = 2000, learning_rate = 0.005, print_cost = True)

# Get id's of correct and incorrect classifications
correctIds = np.empty([1,1], dtype=int)
errorIds = np.empty([1,1], dtype=int)
for idx, label in enumerate(test_set_y[0]):
    if (label == d["Y_prediction_test"][0,idx]):
        correctIds = np.append(correctIds, idx)
    else:
        errorIds = np.append(errorIds, idx)

# Display sample images of correct and incorrect predictions
if (correctIds.shape[0] >= 3 and errorIds.shape[0] >= 3):
    correctIds = np.random.choice(correctIds, 3)
    errorIds = np.random.choice(errorIds, 3)
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',
    }
示例#29
0
    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()
示例#30
0
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())