예제 #1
0
 def scan(self, topdir=''):
     ds = self.dirstate._map.copy()
     self.add_watch(server.join(self.wprefix, topdir), self.mask)
     for root, dirs, files in server.walk(self.dirstate, self.wprefix,
                                          topdir):
         for d in dirs:
             self.add_watch(server.join(root, d), self.mask)
         wroot = root[self.prefixlen:]
         for fn in files:
             wfn = server.join(wroot, fn)
             self.updatefile(wfn, self.getstat(wfn))
             ds.pop(wfn, None)
     wtopdir = topdir
     if wtopdir and wtopdir[-1] != '/':
         wtopdir += '/'
     for wfn, state in ds.iteritems():
         if not wfn.startswith(wtopdir):
             continue
         try:
             st = self.stat(wfn)
         except OSError:
             status = state[0]
             self.deletefile(wfn, status)
         else:
             self.updatefile(wfn, st)
     self.check_deleted('!')
     self.check_deleted('r')
예제 #2
0
 def scan(self, topdir=''):
     ds = self.dirstate._map.copy()
     self.add_watch(server.join(self.wprefix, topdir), self.mask)
     for root, dirs, files in server.walk(self.dirstate, self.wprefix,
                                          topdir):
         for d in dirs:
             self.add_watch(server.join(root, d), self.mask)
         wroot = root[self.prefixlen:]
         for fn in files:
             wfn = server.join(wroot, fn)
             self.updatefile(wfn, self.getstat(wfn))
             ds.pop(wfn, None)
     wtopdir = topdir
     if wtopdir and wtopdir[-1] != '/':
         wtopdir += '/'
     for wfn, state in ds.iteritems():
         if not wfn.startswith(wtopdir):
             continue
         try:
             st = self.stat(wfn)
         except OSError:
             status = state[0]
             self.deletefile(wfn, status)
         else:
             self.updatefile(wfn, st)
     self.check_deleted('!')
     self.check_deleted('r')
예제 #3
0
 def walkit(dirname, top):
     fullpath = server.join(absroot, dirname)
     try:
         for name, kind in osutil.listdir(fullpath):
             if kind == stat.S_IFDIR:
                 if name == '.hg':
                     if not top:
                         return
                 else:
                     d = server.join(dirname, name)
                     if dirstate._ignore(d):
                         continue
                     for subdir in walkit(d, False):
                         yield subdir
     except OSError, err:
         if err.errno not in server.walk_ignored_errors:
             raise
예제 #4
0
 def walkit(dirname, top):
     fullpath = server.join(absroot, dirname)
     try:
         for name, kind in osutil.listdir(fullpath):
             if kind == stat.S_IFDIR:
                 if name == '.hg':
                     if not top:
                         return
                 else:
                     d = server.join(dirname, name)
                     if dirstate._ignore(d):
                         continue
                     for subdir in walkit(d, False):
                         yield subdir
     except OSError, err:
         if err.errno not in server.walk_ignored_errors:
             raise
예제 #5
0
import client
import server

if __name__ == '__main__':
    host = '127.0.0.1'
    port = 34567
    p1 = 0.01
    p2 = 0.01
    p3 = 0.01
    rtt = 0.01
    send_file = 'lena.bmp'
    recv_file = 'recv.bmp'
    client = client.Client(host, port, rtt, p3)
    server = server.Server(host, port, rtt, p1, p2)

    server.save_file(recv_file)
    client.load_file(send_file)

    server.start()
    client.start()

    server.join()
    client.join()
예제 #6
0
    print("===--------------------- SERVEUR ---------------------===")
    print("[MAIN] Démarrage du programme...")
    print("[MAIN] Pour quitter, appuyez sur Ctrl+C.")

    # Crée le serveur.
    server = server.Server()

    # Permet de capturer les interruptions clavier
    # provenant du thread serveur.
    try:
        # Autorise à terminer ce thread si le thread principal (celui-ci) est terminé.
        server.daemon = True

        # Démarre le serveur.
        server.start()

        # Effectue une boucle tant que le serveur est en marche.
        while server.isAlive(): 
            # Attend l'extinction du serveur.
            server.join(1)
    # Signale un SIGINT (interruption clavier)
    # provenant du programme (Ctrl+C).
    except (KeyboardInterrupt, SystemExit):
        # Ne rien faire.
        pass

    # Stop le serveur.
    server.stop()

    print("===---------------------------------------------------===")