Ignore:
Timestamp:
03/24/19 08:15:59 (5 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Ran 2to3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/singleton.py

    r401 r919  
    11
    2 from util import utf2unicode
     2from .util import utf2unicode
    33
    44import os
     
    5959                        break
    6060
    61                     print "singleton._PipeServer.run: created the pipe"
     61                    print("singleton._PipeServer.run: created the pipe")
    6262                    try:
    6363                        if win32pipe.ConnectNamedPipe(handle)==0:
    64                             print "singleton._PipeServer.run: client connection received"
     64                            print("singleton._PipeServer.run: client connection received")
    6565                            (code, message) = \
    6666                                win32file.ReadFile(handle,
     
    6969
    7070                            if code==0:
    71                                 print "singleton._PipeServer.run: message received from client"
     71                                print("singleton._PipeServer.run: message received from client")
    7272                                self._raiseCallback()
    7373                            else:
    74                                 print "singleton._PipeServer.run: failed to read from the pipe"
    75                     except Exception, e:
    76                         print "singleton._PipeServer.run: exception:",
    77                         print utf2unicode(str(e))
     74                                print("singleton._PipeServer.run: failed to read from the pipe")
     75                    except Exception as e:
     76                        print("singleton._PipeServer.run: exception:", end=' ')
     77                        print(utf2unicode(str(e)))
    7878                    finally:
    7979                        win32pipe.DisconnectNamedPipe(handle)
    8080                        win32file.CloseHandle(handle)
    81             except Exception, e:
    82                 print "singleton._PipeServer.run: fatal exception:",
    83                 print utf2unicode(str(e))
     81            except Exception as e:
     82                print("singleton._PipeServer.run: fatal exception:", end=' ')
     83                print(utf2unicode(str(e)))
    8484                           
    8585        def _createPipe(self):
     
    9696                                               None)
    9797            if handle==win32file.INVALID_HANDLE_VALUE:
    98                 print "singleton._PipeServer.run: could not create the handle"
     98                print("singleton._PipeServer.run: could not create the handle")
    9999                return None
    100100            else:
     
    144144                    f.close()
    145145                    return
    146                 except Exception, e:
    147                     print "SingleInstance._notifySingleton: failed:",
    148                     print utf2unicode(str(e))
     146                except Exception as e:
     147                    print("SingleInstance._notifySingleton: failed:", end=' ')
     148                    print(utf2unicode(str(e)))
    149149                    time.sleep(0.5)
    150150       
    151         def __nonzero__(self):
     151        def __bool__(self):
    152152            """Return a boolean representation of the object.
    153153
     
    194194                    s.recv(64)
    195195                    self._raiseCallback()
    196             except Exception, e:
    197                 print "singleton._SocketServer.run: fatal exception:",
    198                 print utf2unicode(str(e))
     196            except Exception as e:
     197                print("singleton._SocketServer.run: fatal exception:", end=' ')
     198                print(utf2unicode(str(e)))
    199199   
    200200    class SingleInstance(object):
     
    218218                fcntl.lockf(self._lockFile, fcntl.LOCK_EX | fcntl.LOCK_NB)
    219219                self._isSingle = True
    220             except Exception, e:
     220            except Exception as e:
    221221                self._lockFile.close()
    222222                self._lockFile = None
     
    259259                    s.close()
    260260                    return
    261                 except Exception, e:
    262                     print "singleton.SingleInstance._notifySingleton: failed:",
    263                     print utf2unicode(str(e))
     261                except Exception as e:
     262                    print("singleton.SingleInstance._notifySingleton: failed:", end=' ')
     263                    print(utf2unicode(str(e)))
    264264                    time.sleep(0.5)
    265265
    266         def __nonzero__(self):
     266        def __bool__(self):
    267267            """Return a boolean representation of the object.
    268268
     
    299299if __name__=="__main__":
    300300    def raiseCallback():
    301         print "Raise the window!"
     301        print("Raise the window!")
    302302
    303303    instance = SingleInstance("mlx", raiseCallback)
    304304    if instance:
    305         print "The first instance"
     305        print("The first instance")
    306306        time.sleep(10)
    307307    else:
    308         print "The program is already running."
    309 
     308        print("The program is already running.")
     309
Note: See TracChangeset for help on using the changeset viewer.