Author: aum
Date: 2006-05-11 01:07:59 +0000 (Thu, 11 May 2006)
New Revision: 8651

Modified:
   trunk/apps/pyFreenet/code.leo
   trunk/apps/pyFreenet/fcp.py
   trunk/apps/pyFreenet/sitemgr.py
Log:
Added help message to sitemgr.py
Remove those (annoying to some) leo markups


Modified: trunk/apps/pyFreenet/code.leo
===================================================================
--- trunk/apps/pyFreenet/code.leo       2006-05-11 00:56:32 UTC (rev 8650)
+++ trunk/apps/pyFreenet/code.leo       2006-05-11 01:07:59 UTC (rev 8651)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <leo_file>
 <leo_header file_format="2" tnodes="0" max_tnode_index="6" clone_windows="0"/>
-<globals body_outline_ratio="0.208333333333">
+<globals body_outline_ratio="0.290740740741">
        <global_window_position top="21" left="104" height="668" width="1080"/>
        <global_log_window_position top="0" left="0" height="0" width="0"/>
 </globals>
@@ -132,7 +132,7 @@
 <v t="aum.20060509223528.119"><vh>exceptions</vh></v>
 </v>
 <v t="aum.20060511003500" tnodeList="aum.20060511003500"><vh>@file 
test.py</vh></v>
-<v t="aum.20060511101147" a="E" 
tnodeList="aum.20060511101147,aum.20060511113333,aum.20060511113333.1,aum.20060511114439,aum.20060511114439.1,aum.20060511114439.2,aum.20060511120059,aum.20060511114604,aum.20060511114604.1,aum.20060511113333.3,aum.20060511120024"><vh>@file
 sitemgr.py</vh>
+<v t="aum.20060511101147" a="E" 
tnodeList="aum.20060511101147,aum.20060511113333,aum.20060511113333.1,aum.20060511114439,aum.20060511114439.1,aum.20060511114439.2,aum.20060511120059,aum.20060511114604,aum.20060511114604.1,aum.20060511113333.3,aum.20060511130507,aum.20060511120024"><vh>@nosent
 sitemgr.py</vh>
 <v t="aum.20060511113333"><vh>imports</vh></v>
 <v t="aum.20060511113333.1"><vh>config</vh></v>
 <v t="aum.20060511114439" a="E"><vh>class SiteMgr</vh>
@@ -141,11 +141,12 @@
 <v t="aum.20060511120059"><vh>createNode</vh></v>
 <v t="aum.20060511114604"><vh>loadConfig</vh></v>
 <v t="aum.20060511114604.1"><vh>saveConfig</vh></v>
-<v t="aum.20060511113333.3" a="V"><vh>update</vh></v>
+<v t="aum.20060511113333.3"><vh>update</vh></v>
 </v>
+<v t="aum.20060511130507" a="V"><vh>help</vh></v>
 <v t="aum.20060511120024"><vh>mainline</vh></v>
 </v>
-<v t="aum.20060506215707" a="E" 
tnodeList="aum.20060506215707,aum.20060506215707.1,aum.20060506220237,aum.20060506215707.2,aum.20060506215707.3,aum.20060506220237.1,aum.20060506220237.2,aum.20060506224238,aum.20060506224238.1,aum.20060506231352,aum.20060507003931,aum.20060511001853,aum.20060506231352.1,aum.20060506232639,aum.20060506232639.1,aum.20060506223545,aum.20060506231352.2,aum.20060506220856,aum.20060506222005,aum.20060507124316,aum.20060511103841,aum.20060511103841.1,aum.20060511103952,aum.20060511103952.1,aum.20060509184020,aum.20060507155016,aum.20060507162314,aum.20060507162543,aum.20060507162314.1,aum.20060509194923,aum.20060507162314.2,aum.20060507162314.3,aum.20060507162543.1,aum.20060507154638,aum.20060507163143,aum.20060509184020.1,aum.20060509184020.2,aum.20060509224119,aum.20060509224221,aum.20060507195029,aum.20060507195029.1,aum.20060506224545"><vh>@file
 fcp.py</vh>
+<v t="aum.20060506215707" a="E" 
tnodeList="aum.20060506215707,aum.20060506215707.1,aum.20060506220237,aum.20060506215707.2,aum.20060506215707.3,aum.20060506220237.1,aum.20060506220237.2,aum.20060506224238,aum.20060506224238.1,aum.20060506231352,aum.20060507003931,aum.20060511001853,aum.20060506231352.1,aum.20060506232639,aum.20060506232639.1,aum.20060506223545,aum.20060506231352.2,aum.20060506220856,aum.20060506222005,aum.20060507124316,aum.20060511103841,aum.20060511103841.1,aum.20060511103952,aum.20060511103952.1,aum.20060509184020,aum.20060507155016,aum.20060507162314,aum.20060507162543,aum.20060507162314.1,aum.20060509194923,aum.20060507162314.2,aum.20060507162314.3,aum.20060507162543.1,aum.20060507154638,aum.20060507163143,aum.20060509184020.1,aum.20060509184020.2,aum.20060509224119,aum.20060509224221,aum.20060507195029,aum.20060507195029.1,aum.20060506224545"><vh>@nosent
 fcp.py</vh>
 <v t="aum.20060506215707.1"><vh>imports</vh></v>
 <v t="aum.20060506220237"><vh>exceptions</vh></v>
 <v t="aum.20060506215707.2"><vh>globals</vh></v>
@@ -6363,6 +6364,8 @@
 
     if not os.path.isfile(configFile):
         self.createConfig()
+        print "New config file created at %s"
+        print "Please edit that file and add your freesites"
             
     self.loadConfig()
 
@@ -6441,6 +6444,9 @@
 </t>
 <t tx="aum.20060511120024">if __name__ == '__main__':
 
+    if '-h' in sys.argv:
+        help()
+
     if '-v' in sys.argv:
         verbosity = fcp.DETAIL
 
@@ -6464,5 +6470,24 @@
     self.node = fcp.FCPNodeConnection(**kw)
 
 </t>
+<t tx="aum.20060511130507">def help():
+    print "%s: A console-based, cron-able freesite inserter" % sys.argv[0]
+    print "This utility inserts/updates freesites, and is"
+    print "driven by a simple config file."
+    print
+    print "The first time you run this utility, a config file"
+    print "will be created for you in your home directory,"
+    print "You will be told where this file is (~/.freesites on *nix"
+    print "or ~/freesites.ini on doze)"
+    print "then you can edit this file and add details of"
+    print "your freesites, and run it again."
+    print
+    print "Note - freesites are only updated if they have"
+    print "changed since the last update, because a hash"
+    print "of each site gets stored in the config"
+
+    sys.exit(0)
+
+</t>
 </tnodes>
 </leo_file>

Modified: trunk/apps/pyFreenet/fcp.py
===================================================================
--- trunk/apps/pyFreenet/fcp.py 2006-05-11 00:56:32 UTC (rev 8650)
+++ trunk/apps/pyFreenet/fcp.py 2006-05-11 01:07:59 UTC (rev 8651)
@@ -1,7 +1,4 @@
 #!/usr/bin/env python
[EMAIL PROTECTED]
[EMAIL PROTECTED]:@file fcp.py
-#@@first
 """
 An implementation of a freenet client library for
 FCP v2
@@ -21,14 +18,10 @@
 
 """
 
[EMAIL PROTECTED]
[EMAIL PROTECTED]:imports
 import sys, os, socket, time, thread, threading, mimetypes, sha
 
 from SimpleXMLRPCServer import SimpleXMLRPCServer
 
[EMAIL PROTECTED]:imports
[EMAIL PROTECTED]:exceptions
 class ConnectionRefused(Exception):
     """
     cannot connect to given host/port
@@ -60,8 +53,6 @@
 class FCPProtocolError(FCPException):
     pass
 
[EMAIL PROTECTED]:exceptions
[EMAIL PROTECTED]:globals
 defaultFCPHost = "127.0.0.1"
 defaultFCPPort = 9481
 
@@ -84,15 +75,11 @@
 DETAIL = 5
 DEBUG = 6
 
[EMAIL PROTECTED]:globals
[EMAIL PROTECTED]:class FCPNodeConnection
 class FCPNodeConnection:
     """
     Low-level transport for connections to
     FCP port
     """
-    #@    @+others
-    [EMAIL PROTECTED]:__init__
     def __init__(self, **kw):
         """
         Create a connection object
@@ -136,8 +123,6 @@
         # launch receiver thread
         #thread.start_new_thread(self.rxThread, ())
     
-    [EMAIL PROTECTED]:__init__
-    [EMAIL PROTECTED]:__del__
     def __del__(self):
         """
         object is getting cleaned up, so disconnect
@@ -149,12 +134,8 @@
         if self.logfile not in [sys.stdout, sys.stderr]:
             self.logfile.close()
     
-    [EMAIL PROTECTED]:__del__
-    [EMAIL PROTECTED]:High Level Methods
     # high level client methods
     
-    [EMAIL PROTECTED]
-    [EMAIL PROTECTED]:hello
     def hello(self):
         
         self._sendMessage("ClientHello", 
@@ -164,8 +145,6 @@
         resp = self._receiveMessage()
         return resp
     
-    [EMAIL PROTECTED]:hello
-    [EMAIL PROTECTED]:get
     def get(self, uri, **kw):
         """
         Does a direct get of a key
@@ -262,8 +241,6 @@
         else:
             raise FCPException(resp)
     
-    [EMAIL PROTECTED]:get
-    [EMAIL PROTECTED]:put
     def put(self, uri="CHK@", **kw):
         """
         Inserts a key
@@ -415,8 +392,6 @@
         else:
             raise FCPException(resp2)
     
-    [EMAIL PROTECTED]:put
-    [EMAIL PROTECTED]:putdir
     def putdir(self, uri, **kw):
         """
         Inserts a freesite
@@ -515,8 +490,6 @@
         else:
             raise FCPException(resp2)
     
-    [EMAIL PROTECTED]:putdir
-    [EMAIL PROTECTED]:genkey
     def genkey(self, id=None):
         """
         Generates and returns an SSK keypair
@@ -535,17 +508,11 @@
     
         return resp['RequestURI'], resp['InsertURI']
     
-    [EMAIL PROTECTED]:genkey
-    [EMAIL PROTECTED]
     
     
     
-    [EMAIL PROTECTED]:High Level Methods
-    [EMAIL PROTECTED]:Receiver Thread
     # methods for receiver thread
     
-    [EMAIL PROTECTED]
-    [EMAIL PROTECTED]:_rxThread
     def _rxThread(self):
         """
         Receives all incoming messages
@@ -559,20 +526,12 @@
                 self.socketLock.release()
                 continue
             
-    [EMAIL PROTECTED]:_rxThread
-    [EMAIL PROTECTED]
     
-    [EMAIL PROTECTED]:Receiver Thread
-    [EMAIL PROTECTED]:Low Level Methods
     # low level noce comms methods
     
-    [EMAIL PROTECTED]
-    [EMAIL PROTECTED]:_getUniqueId
     def _getUniqueId(self):
         return "id" + str(int(time.time() * 1000000))
     
-    [EMAIL PROTECTED]:_getUniqueId
-    [EMAIL PROTECTED]:_sendMessage
     def _sendMessage(self, msgType, sendEndMessage=True, **kw):
         """
         low level message send
@@ -614,8 +573,6 @@
     
         self.socket.send(raw)
     
-    [EMAIL PROTECTED]:_sendMessage
-    [EMAIL PROTECTED]:_receiveMessage
     def _receiveMessage(self):
         """
         Receives and returns a message as a dict
@@ -697,8 +654,6 @@
         # all done
         return items
     
-    [EMAIL PROTECTED]:_receiveMessage
-    [EMAIL PROTECTED]:_log
     def _log(self, level, msg):
         """
         Logs a message. If level > verbosity, don't output it
@@ -710,10 +665,6 @@
         self.logfile.write(msg)
         self.logfile.flush()
     
-    [EMAIL PROTECTED]:_log
-    [EMAIL PROTECTED]
-    [EMAIL PROTECTED]:Low Level Methods
-    [EMAIL PROTECTED]:class JobTicket
     class JobTicket:
         """
         A JobTicket is an object returned to clients making
@@ -725,8 +676,6 @@
             - poll the job for completion status
             - receive a callback upon completion
         """
-        #@    @+others
-        [EMAIL PROTECTED]:__init__
         def __init__(self, id):
             """
             You should never instantiate a JobTicket object yourself
@@ -734,56 +683,36 @@
             self.id = id
             self.queue = Queue.Queue()
         
-        [EMAIL PROTECTED]:__init__
-        [EMAIL PROTECTED]:isDone
         def isComplete(self):
             """
             Returns True if the job has been completed
             """
         
-        [EMAIL PROTECTED]:isDone
-        [EMAIL PROTECTED]:wait
         def wait(self, timeout=None):
             """
             Waits forever (or for a given timeout) for a job to complete
             """
-        [EMAIL PROTECTED]:wait
-        [EMAIL PROTECTED]
     
-    [EMAIL PROTECTED]:class JobTicket
-    [EMAIL PROTECTED]
 
[EMAIL PROTECTED]:class FCPNodeConnection
[EMAIL PROTECTED]:XML-RPC Server
[EMAIL PROTECTED]
[EMAIL PROTECTED]:class FreenetXMLRPCRequest
 class FreenetXMLRPCRequest:
     """
     Simple class which exposes basic primitives
     for freenet xmlrpc server
     """
-    #@    @+others
-    [EMAIL PROTECTED]:__init__
     def __init__(self, **kw):
     
         self.kw = kw
     
-    [EMAIL PROTECTED]:__init__
-    [EMAIL PROTECTED]:_getNode
     def _getNode(self):
         
         node = FCPNodeConnection(**self.kw)
         node.hello()
         return node
     
-    [EMAIL PROTECTED]:_getNode
-    [EMAIL PROTECTED]:_hello
     def _hello(self):
         
         self.node.hello()
     
-    [EMAIL PROTECTED]:_hello
-    [EMAIL PROTECTED]:hello
     def hello(self):
         """
         pings the FCP interface. just creates the connection,
@@ -794,8 +723,6 @@
     
         node = self._getNode()
     
-    [EMAIL PROTECTED]:hello
-    [EMAIL PROTECTED]:get
     def get(self, uri, options=None):
         """
         Performs a fetch of a key
@@ -812,8 +739,6 @@
     
         return node.get(uri, **options)
     
-    [EMAIL PROTECTED]:get
-    [EMAIL PROTECTED]:put
     def put(self, uri, options=None):
         """
         Inserts data to node
@@ -830,19 +755,13 @@
     
         return node.put(uri, data=data, **options)
     
-    [EMAIL PROTECTED]:put
-    [EMAIL PROTECTED]:genkey
     def genkey(self):
         
         node = self._getNode()
     
         return self.node.genkey()
     
-    [EMAIL PROTECTED]:genkey
-    [EMAIL PROTECTED]
 
[EMAIL PROTECTED]:class FreenetXMLRPCRequest
[EMAIL PROTECTED]:runServer
 def runServer(**kw):
     """
     Runs a basic XML-RPC server for FCP access
@@ -859,19 +778,11 @@
     server.register_introspection_methods()
     server.serve_forever()
 
[EMAIL PROTECTED]:runServer
[EMAIL PROTECTED]:testServer
 def testServer():
     
     runServer(host="", fcpHost="10.0.0.1", verbosity=DETAIL)
 
[EMAIL PROTECTED]:testServer
[EMAIL PROTECTED]
 
[EMAIL PROTECTED]:XML-RPC Server
[EMAIL PROTECTED]:util funcs
[EMAIL PROTECTED]
[EMAIL PROTECTED]:toBool
 def toBool(arg):
     try:
         arg = int(arg)
@@ -891,8 +802,6 @@
     else:
         return False
 
[EMAIL PROTECTED]:toBool
[EMAIL PROTECTED]:readdir
 def readdir(dirpath, prefix='', gethashes=False):
     """
     Reads a directory, returning a sequence of file dicts.
@@ -941,8 +850,6 @@
 
     return entries
 
[EMAIL PROTECTED]:readdir
[EMAIL PROTECTED]:guessMimetype
 def guessMimetype(filename):
     """
     Returns a guess of a mimetype based on a filename's extension
@@ -951,11 +858,7 @@
     if m == None:
         m = "text/plain"
     return m
[EMAIL PROTECTED]:guessMimetype
[EMAIL PROTECTED]
 
[EMAIL PROTECTED]:util funcs
[EMAIL PROTECTED]:usage
 def usage(msg="", ret=1):
 
     if msg:
@@ -988,8 +891,6 @@
 
     sys.exit(ret)
 
[EMAIL PROTECTED]:usage
[EMAIL PROTECTED]:main
 def main():
     """
     When this script is executed, it runs the XML-RPC server
@@ -1050,14 +951,8 @@
 
 
 
[EMAIL PROTECTED]:main
[EMAIL PROTECTED]:mainline
 if __name__ == '__main__':
     
     main()
 
[EMAIL PROTECTED]:mainline
[EMAIL PROTECTED]
 
[EMAIL PROTECTED]:@file fcp.py
[EMAIL PROTECTED]

Modified: trunk/apps/pyFreenet/sitemgr.py
===================================================================
--- trunk/apps/pyFreenet/sitemgr.py     2006-05-11 00:56:32 UTC (rev 8650)
+++ trunk/apps/pyFreenet/sitemgr.py     2006-05-11 01:07:59 UTC (rev 8651)
@@ -1,32 +1,21 @@
 #! /usr/bin/env python
[EMAIL PROTECTED]
[EMAIL PROTECTED]:@file sitemgr.py
-#@@first
 """
 A small freesite insertion/management utility
 """
[EMAIL PROTECTED]
[EMAIL PROTECTED]:imports
 import fcp, sys, os, sha
 
 from ConfigParser import SafeConfigParser
 
[EMAIL PROTECTED]:imports
[EMAIL PROTECTED]:config
 fcpHost = "thoth"
 fcpPort = None
 #verbosity = fcp.DETAIL
 verbosity = None
 logfile = None
 
[EMAIL PROTECTED]:config
[EMAIL PROTECTED]:class SiteMgr
 class SiteMgr:
     """
     Manages insertion and updating of freesites
     """
-    #@    @+others
-    [EMAIL PROTECTED]:__init__
     def __init__(self, configFile=None, **kw):
         """
         Creates a site manager object.
@@ -52,11 +41,11 @@
     
         if not os.path.isfile(configFile):
             self.createConfig()
+            print "New config file created at %s"
+            print "Please edit that file and add your freesites"
                 
         self.loadConfig()
     
-    [EMAIL PROTECTED]:__init__
-    [EMAIL PROTECTED]:createConfig
     def createConfig(self):
         """
         Creates a whole new config
@@ -79,8 +68,6 @@
             "",
             ]))
     
-    [EMAIL PROTECTED]:createConfig
-    [EMAIL PROTECTED]:createNode
     def createNode(self, **kw):
     
         kw = {}
@@ -96,8 +83,6 @@
         
         self.node = fcp.FCPNodeConnection(**kw)
     
-    [EMAIL PROTECTED]:createNode
-    [EMAIL PROTECTED]:loadConfig
     def loadConfig(self):
         """
         Loads the sites config file into self.config as a SafeConfigParser
@@ -133,8 +118,6 @@
         if needToSave:
             self.saveConfig()
     
-    [EMAIL PROTECTED]:loadConfig
-    [EMAIL PROTECTED]:saveConfig
     def saveConfig(self):
         """
         Saves the amended config file to disk
@@ -147,8 +130,6 @@
     
         f.close()
     
-    [EMAIL PROTECTED]:saveConfig
-    [EMAIL PROTECTED]:update
     def update(self):
         """
         Insert/update all registered freesites
@@ -180,20 +161,33 @@
         if noSites:
             print "No sites needed updating"
     
-    [EMAIL PROTECTED]:update
-    [EMAIL PROTECTED]
 
[EMAIL PROTECTED]:class SiteMgr
[EMAIL PROTECTED]:mainline
+def help():
+    print "%s: A console-based, cron-able freesite inserter" % sys.argv[0]
+    print "This utility inserts/updates freesites, and is"
+    print "driven by a simple config file."
+    print
+    print "The first time you run this utility, a config file"
+    print "will be created for you in your home directory,"
+    print "You will be told where this file is (~/.freesites on *nix"
+    print "or ~/freesites.ini on doze)"
+    print "then you can edit this file and add details of"
+    print "your freesites, and run it again."
+    print
+    print "Note - freesites are only updated if they have"
+    print "changed since the last update, because a hash"
+    print "of each site gets stored in the config"
+
+    sys.exit(0)
+
 if __name__ == '__main__':
 
+    if '-h' in sys.argv:
+        help()
+
     if '-v' in sys.argv:
         verbosity = fcp.DETAIL
 
     s = SiteMgr()
     s.update()
 
[EMAIL PROTECTED]:mainline
[EMAIL PROTECTED]
[EMAIL PROTECTED]:@file sitemgr.py
[EMAIL PROTECTED]

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to