コード例 #1
0
ファイル: uploadclient.py プロジェクト: vaginessa/PySpeedTest
    def send_data(self):
        if not self.has_connection:
            raise ValueError("Can't upload data with no connection!")

        self.handler.set_label(2, 'Reading file')

        try:
            with open(REC_FILE, 'r') as infile:
                self.lines = infile.readlines()
        except IOError:
            self.lines = []  # let the handler on the next step handle this

        if not self.lines:
            errors.display_error(
                IOError("File contains no data or is not"
                        " found on disk!"))
            return

        outlines = copy.deepcopy(self.lines)

        for line in self.lines:
            self.handler.set_label(2, line)
            encoded = encoder(line)
            try:
                self.socket.sendall(encoded)
            except (socket.gaierror, socket.timeout, socket.error):
                # timeout, stop trying
                self.handler.set_label(2, "Connection lost")
                break
            outlines.remove(line)

        self.handler.set_label(2, 'Clearing file')
        with open(REC_FILE, 'w') as handle:
            handle.writelines(outlines)
コード例 #2
0
 def make_analysis_file(self):
     """
     Create the statistical analysis file.
     """
     try:
         run_analytics()
     except Exception as exc:
         errors.display_error(exc, False)
コード例 #3
0
ファイル: uploadclient.py プロジェクト: fighcell/PySpeedTest
    def send_data(self):
        if not self.has_connection:
            raise ValueError("Can't upload data with no connection!")

        self.set_label(2, 'Reading file')

        with open(REC_FILE, 'r') as infile:
            self.lines = infile.readlines()

        if not self.lines:
            errors.display_error(
                IOError("File contains no data or is not"
                        " found on disk!"))
            return

        for line in self.lines:
            self.set_label(2, line)
            encoded = encoder(line)
            self.socket.sendall(encoded)

        self.set_label(2, 'Clearing file')
        with open(REC_FILE, 'w') as handle:
            handle.write('')
コード例 #4
0
ファイル: settings.py プロジェクト: vaginessa/PySpeedTest
    FORCE_SERVER = None if server == 'None' else server

    ANALYZE_FILE = resource_path(parser.get('Analytics', 'analyze_file'))
    ANALYTICS_REC_FILE = resource_path(
        parser.get('Analytics', 'analytics_rec_file'))
    STANDARDS_ENABLE = parser.get('Analytics', 'standards_enable') in \
        ['true', '1', 't', 'y', 'yes',
         'yeah', 'yup', 'certainly', 'uh-huh']
    STANDARD_PING = float(parser.get('Analytics', 'standard_ping') or 0)
    STANDARD_DOWN = float(parser.get('Analytics', 'standard_down') or 0)
    STANDARD_UP = float(parser.get('Analytics', 'standard_up') or 0)

    CSV_INPUT_FILE = resource_path(parser.get('CSV', 'csv_input_file'))
    CSV_OUTPUT_FILE = resource_path(parser.get('CSV', 'csv_output_file'))
    CSV_CLEAR_INFILE = resource_path(parser.get('CSV', 'csv_clear_infile'))

    UPLOAD_PORT = int(parser.get('Upload', 'port'))
    url_items = parser.items('UploadURLs')
    UPLOAD_URLS = []
    for key, path in url_items:
        UPLOAD_URLS.append(path)
except (configparser.NoSectionError, configparser.NoOptionError) as exc:
    with open(CONFIG_FILE_NAME, 'w') as conf:
        conf.write(EMERGENCY_DEFAULT)

    msg = "\n\nThere was an error loading the configuration file.  Maybe\n"
    msg += "you updated the problem recently?  I restored it to the\n"
    msg += "default state, try loading the program again.\n\n"

    errors.display_error(Exception(msg))
コード例 #5
0
        self.upload_button = tk.Button(self.root,
                                       text="Upload",
                                       command=self.upload_data)
        self.upload_button.grid(row=3, column=1, sticky=tk.W)

        self.thread_status = tk.Label(self.root, text="Thread status:")
        self.thread_status.grid(row=4, column=0, columnspan=3, sticky=tk.W)
        self.last_test_label = tk.Label(self.root, text="Last: ")
        self.last_test_label.grid(row=5, column=0, columnspan=3, sticky=tk.W)

        self.avg_test_label = tk.Label(self.root, text="Avg.: ")
        self.avg_test_label.grid(row=6, column=0, columnspan=3, sticky=tk.W)

        self.config_button = tk.Button(self.root,
                                       text="Edit configuration",
                                       command=self.edit_config)
        self.config_button.grid(row=7, column=0, sticky=tk.W)

        self.resnet_button = tk.Button(self.root,
                                       text="ResNet",
                                       command=self.resnet)
        self.resnet_button.grid(row=7, column=1, sticky=tk.W)


if __name__ == '__main__':

    try:
        stg = SpeedTesterGUI()
    except Exception as exc:
        errors.display_error(exc, raise_when_done=False)