Hébergeur de fichiers indépendant

pping.py

À propos du fichier

Type de fichier
Fichier PY de 2 Ko (text/x-python)
Confidentialité
Fichier public, envoyé le 25 juillet 2013 à 15:29, depuis l'adresse IP 82.227.x.x (France)
Sécurité
Ne contient aucun Virus ou Malware connus - Dernière vérification: 3 jours
Statistiques
La présente page de téléchargement a été vue 960 fois depuis l'envoi du fichier
Page de téléchargement

Aperçu du fichier


#! /usr/bin/env python
# -*- coding: utf-8 -*-

import subprocess
from gi.repository import Gtk, GObject

class ProgressBarWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="Temps de réponse du Net")
        self.set_border_width(10)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.add(vbox)

        self.progressbar = Gtk.ProgressBar()
        vbox.pack_start(self.progressbar, True, True, 0)

        self.label = Gtk.Label()
        self.label.set_text("            Valeur du ping = 00.0 ms            ")
        vbox.pack_start(self.label, True, True, 0)

        self.timeout_id = GObject.timeout_add(250, self.on_timeout, None)


    def on_timeout(self, user_data):
        """
        Mise à jor de la barre de progression
        """
        list = subprocess.Popen(["/usr/bin/ping", "-c", "1", "google.fr"],
                                                 shell=False, stdout=subprocess.PIPE)
        output = list.stdout.readline().decode()
        if output != "" :
            output = list.stdout.readline().decode()
            i = output.find("time=")
            i = i + 5
            s1 = output[i:]
            i = s1.find(" ")
            s2 = s1[0:i]
            new_value = float(s2) / 50.0
            if new_value > 1.0 :
                new_value = 1.0
            self.progressbar.set_fraction(new_value)
            self.label.set_text("            Valeur du ping = " + s2 + " ms            ")
        return True

win = ProgressBarWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()


Partager le fichier pping.py sur le Web et les réseaux sociaux:


Télécharger le fichier pping.py


Télécharger pping.py