Return a string result with out breaking loop

Andrew nobody at
Tue Aug 26 04:14:39 CEST 2008

I run the server then execute the client. From the client I execute the 
function key.watchos()

My goal is an administration tool

and this is just a function in my goal :-)

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Maboroshi>python C:\software\mabssystem\
Use the keyword, "key" to interact with the server
 >>> key.watchos()
Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "C:\Python25\lib\", line 1147, in __call__
     return self.__send(self.__name, args)
   File "C:\Python25\lib\", line 1437, in __request
   File "C:\Python25\lib\", line 1201, in request
     return self._parse_response(h.getfile(), sock)
   File "C:\Python25\lib\", line 1340, in _parse_response
     return u.close()
   File "C:\Python25\lib\", line 787, in close
     raise Fault(**self._stack[0])
Fault: <Fault 1: "<type 'exceptions.TypeError'>:cannot marshal <type 
 > objects">

the function watchos is basically based off of Tim Goldens Directory 
watching app

the function is as follows in entirety

     def watchos(self, path_to_watch="C:\\"):
         #get path or maintain current path of app
         FILE_LIST_DIRECTORY = 0x0001
         try: path_to_watch or "."
         except: path_to_watch = "."
         path_to_watch = os.path.abspath(path_to_watch)

         out1 = "Watching %s at %s" % (path_to_watch, time.asctime()) + 
         # FindFirstChangeNotification sets up a handle for watching
         #  file changes.
         while 1:

             hDir = win32file.CreateFile (
                 win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE,

             change_handle = win32file.ReadDirectoryChangesW (
                 True,#Heap Size include_subdirectories,
                 win32con.FILE_NOTIFY_CHANGE_FILE_NAME |
                 win32con.FILE_NOTIFY_CHANGE_DIR_NAME |
                 win32con.FILE_NOTIFY_CHANGE_ATTRIBUTES |
                 win32con.FILE_NOTIFY_CHANGE_SIZE |
                 win32con.FILE_NOTIFY_CHANGE_LAST_WRITE |

             # Loop forever, listing any file changes. The WaitFor... will
             #  time out every half a second allowing for keyboard 
             #  to terminate the loop.
             ACTIONS = {
                 1 : "Created",
                 2 : "Deleted",
                 3 : "Updated",
                 4 : "Renamed from something",
                 5 : "Renamed to something"

             results = change_handle
             for action, files in results:
                 full_filename = os.path.join(path_to_watch, files)
                 theact = ACTIONS.get(action, "Unknown")
                 yield str(full_filename) +  " " + str(theact)

and the rpc client is as follows

import xmlrpclib, code

# Specify IP of Server here defualt port is 9000
url = ""
sock = xmlrpclib.ServerProxy(url, allow_none=True, verbose=0)
# use the interactive console to interact example "key.keyit()" will 
start the logger
interp = code.InteractiveConsole({'key': sock})
interp.interact("Use the keyword, \"key\" to interact with the server")

Sorry if I posted to much code :-)

Thank you in advance

More information about the Python-list mailing list