Author: aum
Date: 2006-06-04 08:18:29 +0000 (Sun, 04 Jun 2006)
New Revision: 9042

Modified:
   trunk/apps/pyFreenet/code.leo
   trunk/apps/pyFreenet/fcpget
   trunk/apps/pyFreenet/fcpget.py
   trunk/apps/pyFreenet/fcpput
   trunk/apps/pyFreenet/fcpput.py
   trunk/apps/pyFreenet/freedisk.py
Log:
fix stuff


Modified: trunk/apps/pyFreenet/code.leo
===================================================================
--- trunk/apps/pyFreenet/code.leo       2006-06-04 08:10:02 UTC (rev 9041)
+++ trunk/apps/pyFreenet/code.leo       2006-06-04 08:18:29 UTC (rev 9042)
@@ -300,7 +300,7 @@
 <v t="aum.20060521131205"><vh>globals</vh></v>
 <v t="aum.20060521131205.1"><vh>usage</vh></v>
 <v t="aum.20060521131205.2"><vh>help</vh></v>
-<v t="aum.20060521111727.2" a="V"><vh>main</vh></v>
+<v t="aum.20060521111727.2"><vh>main</vh></v>
 <v t="aum.20060521111727.3"><vh>mainline</vh></v>
 </v>
 </v>
@@ -322,7 +322,7 @@
 <v t="aum.20060521134737.2"><vh>globals</vh></v>
 <v t="aum.20060521134737.3"><vh>usage</vh></v>
 <v t="aum.20060521134737.4"><vh>help</vh></v>
-<v t="aum.20060521134737.5"><vh>main</vh></v>
+<v t="aum.20060521134737.5" a="V"><vh>main</vh></v>
 <v t="aum.20060521134737.6"><vh>mainline</vh></v>
 </v>
 </v>
@@ -8804,11 +8804,12 @@
     try:
         cmdopts, args = getopt.getopt(
             sys.argv[1:],
-            "?hvH:P:g",
+            "?hvH:P:gp:",
             ["help", "verbose", "fcpHost=", "fcpPort=", "global", 
"persistence=",
              ]
             )
     except getopt.GetoptError:
+        #traceback.print_exc()
         # print help information and exit:
         usage()
         sys.exit(2)
@@ -9071,7 +9072,7 @@
     try:
         cmdopts, args = getopt.getopt(
             sys.argv[1:],
-            "?hvH:P:m:g",
+            "?hvH:P:m:gp:",
             ["help", "verbose", "fcpHost=", "fcpPort=", "mimetype=", "global",
              "persistence=",
              ]
@@ -11851,129 +11852,146 @@
         opts['multithreaded'] = True

 </t>
-<t tx="aum.20060530143459.3">
-print "starting freedisk service..."
-fs = freenetfs.FreenetFS(
-        conf.mountpoint,
-        fcpHost=conf.fcpHost,
-        fcpPort=conf.fcpPort,
-        verbosity=conf.fcpVerbosity,
-        debug=debug,
-        multithreaded=multithreaded,
-        )
+<t tx="aum.20060530143459.3">def cmd_start(self, *args):

-# spawn a process to run it
-if os.fork() == 0:
-    print "Mounting freenet fs at %s" % conf.mountpoint
-    fs.run()
-else:
-    # parent process
-    keyDir = os.path.join(conf.mountpoint, "keys")
-    print "Waiting for disk to come up..."
-    while not os.path.isdir(keyDir):
-        time.sleep(1)
-    disks = conf.getDisks()
-
-    if disks:
-        print "Freenetfs now mounted, adding existing disks..."
+    print "starting freedisk service..."
+    fs = freenetfs.FreenetFS(
+            conf.mountpoint,
+            fcpHost=conf.fcpHost,
+            fcpPort=conf.fcpPort,
+            verbosity=conf.fcpVerbosity,
+            debug=debug,
+            multithreaded=multithreaded,
+            )
+    
+    # spawn a process to run it
+    if os.fork() == 0:
+        print "Mounting freenet fs at %s" % conf.mountpoint
+        fs.run()
     else:
-        print "Freenetfs now mounted, no freedisks at present"
+        # parent process
+        keyDir = os.path.join(conf.mountpoint, "keys")
+        print "Waiting for disk to come up..."
+        while not os.path.isdir(keyDir):
+            time.sleep(1)
+        disks = conf.getDisks()
+    
+        if disks:
+            print "Freenetfs now mounted, adding existing disks..."
+        else:
+            print "Freenetfs now mounted, no freedisks at present"
+    
+        for disk in disks:
+    
+            diskPath = os.path.join(conf.mountpoint, "usr", disk.name)
+    
+            # barf if a freedisk of that name is already mounted
+            if os.path.exists(diskPath):
+                usage("Freedisk %s seems to be already mounted" % disk.name)
+            
+            # mkdir to create the freedisk dir
+            os.mkdir(diskPath)
+    
+            pubKeyPath = os.path.join(diskPath, ".publickey")
+            privKeyPath = os.path.join(diskPath, ".privatekey")
+            passwdPath = os.path.join(diskPath, ".passwd")
+    
+            # wait for the pseudo-files to come into existence
+            while not os.path.isfile(privKeyPath):
+                time.sleep(0.1)
+    
+            # set the key and password
+            file(pubKeyPath, "w").write(disk.uri)
+            file(privKeyPath, "w").write(disk.privUri)
+            file(passwdPath, "w").write(disk.passwd)
+            
+    </t>
+<t tx="aum.20060530143459.4">def cmd_stop(self, *args):
+    """
+    Unmount the freenetfs
+    """
+    os.system("umount %s" % self.conf.mountpoint)

-    for disk in disks:
-
-        diskPath = os.path.join(conf.mountpoint, "usr", disk.name)
-
-        # barf if a freedisk of that name is already mounted
-        if os.path.exists(diskPath):
-            usage("Freedisk %s seems to be already mounted" % disk.name)
-        
-        # mkdir to create the freedisk dir
-        os.mkdir(diskPath)
-
-        pubKeyPath = os.path.join(diskPath, ".publickey")
-        privKeyPath = os.path.join(diskPath, ".privatekey")
-        passwdPath = os.path.join(diskPath, ".passwd")
-
-        # wait for the pseudo-files to come into existence
-        while not os.path.isfile(privKeyPath):
-            time.sleep(0.1)
-
-        # set the key and password
-        file(pubKeyPath, "w").write(disk.uri)
-        file(privKeyPath, "w").write(disk.privUri)
-        file(passwdPath, "w").write(disk.passwd)
-        
 </t>
-<t tx="aum.20060530143459.4">os.system("umount %s" % conf.mountpoint)
+<t tx="aum.20060530143459.5">def cmd_new(self, *args):
+    """
+    Creates a new freedisk with a random key
+    """
+    #print "new: %s: NOT IMPLEMENTED" % diskname
+    
+    conf = self.conf
+    diskname = self.diskname
+    diskPath = self.diskPath

-</t>
-<t tx="aum.20060530143459.5">#print "new: %s: NOT IMPLEMENTED" % diskname
+    if os.path.exists(diskPath):
+        usage("Freedisk %s seems to be already mounted" % diskname)
+    
+    # get a password if desired
+    passwd = getpasswd("Encrypt disk with password", True)
+    
+    # get a new private key
+    keyDir = os.path.join(conf.mountpoint, "keys")
+    if not os.path.isdir(keyDir):
+        print "No keys directory %s" % keyDir
+        print "Is your freenetfs mounted?"
+        usage("Freenetfs not mounted")
+    keyName = "freedisk_%s_%s" % (diskname, int(time.time()*1000000))
+    keyPath = os.path.join(keyDir, keyName)
+    
+    keys = file(keyPath).read().strip().split("\n")
+    pubKey, privKey = [k.split("/")[0].split("freenet:")[-1] for k in keys]
+    
+    # mkdir to create the freedisk dir
+    os.mkdir(diskPath)
+    
+    # wait for the pseudo-files to come into existence
+    while not os.path.isfile(privKeyPath):
+        time.sleep(0.1)
+    
+    #status("About to write to %s" % privKeyPath)
+    
+    file(self.pubKeyPath, "w").write(pubKey)
+    file(self.privKeyPath, "w").write(privKey)
+    file(self.passwdPath, "w").write(passwd)
+    
+    # and, of course, update config
+    conf.addDisk(diskname, pubKey, privKey, passwd)
+    
+    </t>
+<t tx="aum.20060530143459.6">def cmd_add(self, *args):

-if os.path.exists(diskPath):
-    usage("Freedisk %s seems to be already mounted" % diskname)
+    nargs = len(args)

-# get a password if desired
-passwd = getpasswd("Encrypt disk with password", True)
+    # get uri
+    if nargs &lt; 3:
+        usage("add: Missing URI")
+    uri = args[1]

-# get a new private key
-keyDir = os.path.join(conf.mountpoint, "keys")
-if not os.path.isdir(keyDir):
-    print "No keys directory %s" % keyDir
-    print "Is your freenetfs mounted?"
-    usage("Freenetfs not mounted")
-keyName = "freedisk_%s_%s" % (diskname, int(time.time()*1000000))
-keyPath = os.path.join(keyDir, keyName)
-
-keys = file(keyPath).read().strip().split("\n")
-pubKey, privKey = [k.split("/")[0].split("freenet:")[-1] for k in keys]
-
-# mkdir to create the freedisk dir
-os.mkdir(diskPath)
-
-# wait for the pseudo-files to come into existence
-while not os.path.isfile(privKeyPath):
-    time.sleep(0.1)
-
-#status("About to write to %s" % privKeyPath)
-
-file(pubKeyPath, "w").write(pubKey)
-file(privKeyPath, "w").write(privKey)
-file(passwdPath, "w").write(passwd)
-
-# and, of course, update config
-conf.addDisk(diskname, pubKey, privKey, passwd)
-
-</t>
-<t tx="aum.20060530143459.6"># get uri
-if nargs &lt; 3:
-    usage("add: Missing URI")
-uri = args[2]
-
-#print "add: %s: NOT IMPLEMENTED" % diskname
-
-# barf if a freedisk of that name is already mounted
-if os.path.exists(diskPath):
-    usage("Freedisk %s seems to be already mounted" % diskname)
-
-# mkdir to create the freedisk dir
-os.mkdir(diskPath)
-
-# wait for the pseudo-files to come into existence
-while not os.path.isfile(privKeyPath):
-    time.sleep(0.1)
-
-# set the keys
-
-if fcp.node.uriIsPrivate(uri):
-    path = privKeyPath
-else:
-    path = pubKeyPath
-f = file(path, "w")
-f.write(uri)
-f.flush()
-f.close()
-
-</t>
+    #print "add: %s: NOT IMPLEMENTED" % diskname
+    
+    # barf if a freedisk of that name is already mounted
+    if os.path.exists(self.diskPath):
+        usage("Freedisk %s seems to be already mounted" % diskname)
+    
+    # mkdir to create the freedisk dir
+    os.mkdir(self.diskPath)
+    
+    # wait for the pseudo-files to come into existence
+    while not os.path.isfile(self.privKeyPath):
+        time.sleep(0.1)
+    
+    # set the keys
+    
+    if fcp.node.uriIsPrivate(uri):
+        path = privKeyPath
+    else:
+        path = pubKeyPath
+    f = file(path, "w")
+    f.write(uri)
+    f.flush()
+    f.close()
+    
+    </t>
 <t tx="aum.20060530143459.7">disk = conf.getDisk(diskname)

 if not isinstance(disk, XMLNode):
@@ -12859,8 +12877,10 @@
     return method(*self.args[1:])

 </t>
-<t tx="aum.20060604200719">mgr = FreediskMgr(**opts)
+<t tx="aum.20060604200719">mgr = FreediskMgr(*args, **opts)

+mgr.run()
+
 </t>
 </tnodes>
 </leo_file>

Modified: trunk/apps/pyFreenet/fcpget
===================================================================
--- trunk/apps/pyFreenet/fcpget 2006-06-04 08:10:02 UTC (rev 9041)
+++ trunk/apps/pyFreenet/fcpget 2006-06-04 08:18:29 UTC (rev 9042)
@@ -77,11 +77,12 @@
     try:
         cmdopts, args = getopt.getopt(
             sys.argv[1:],
-            "?hvH:P:g",
+            "?hvH:P:gp:",
             ["help", "verbose", "fcpHost=", "fcpPort=", "global", 
"persistence=",
              ]
             )
     except getopt.GetoptError:
+        #traceback.print_exc()
         # print help information and exit:
         usage()
         sys.exit(2)

Modified: trunk/apps/pyFreenet/fcpget.py
===================================================================
--- trunk/apps/pyFreenet/fcpget.py      2006-06-04 08:10:02 UTC (rev 9041)
+++ trunk/apps/pyFreenet/fcpget.py      2006-06-04 08:18:29 UTC (rev 9042)
@@ -77,11 +77,12 @@
     try:
         cmdopts, args = getopt.getopt(
             sys.argv[1:],
-            "?hvH:P:g",
+            "?hvH:P:gp:",
             ["help", "verbose", "fcpHost=", "fcpPort=", "global", 
"persistence=",
              ]
             )
     except getopt.GetoptError:
+        #traceback.print_exc()
         # print help information and exit:
         usage()
         sys.exit(2)

Modified: trunk/apps/pyFreenet/fcpput
===================================================================
--- trunk/apps/pyFreenet/fcpput 2006-06-04 08:10:02 UTC (rev 9041)
+++ trunk/apps/pyFreenet/fcpput 2006-06-04 08:18:29 UTC (rev 9042)
@@ -81,7 +81,7 @@
     try:
         cmdopts, args = getopt.getopt(
             sys.argv[1:],
-            "?hvH:P:m:g",
+            "?hvH:P:m:gp:",
             ["help", "verbose", "fcpHost=", "fcpPort=", "mimetype=", "global",
              "persistence=",
              ]

Modified: trunk/apps/pyFreenet/fcpput.py
===================================================================
--- trunk/apps/pyFreenet/fcpput.py      2006-06-04 08:10:02 UTC (rev 9041)
+++ trunk/apps/pyFreenet/fcpput.py      2006-06-04 08:18:29 UTC (rev 9042)
@@ -81,7 +81,7 @@
     try:
         cmdopts, args = getopt.getopt(
             sys.argv[1:],
-            "?hvH:P:m:g",
+            "?hvH:P:m:gp:",
             ["help", "verbose", "fcpHost=", "fcpPort=", "mimetype=", "global",
              "persistence=",
              ]

Modified: trunk/apps/pyFreenet/freedisk.py
===================================================================
--- trunk/apps/pyFreenet/freedisk.py    2006-06-04 08:10:02 UTC (rev 9041)
+++ trunk/apps/pyFreenet/freedisk.py    2006-06-04 08:18:29 UTC (rev 9042)
@@ -171,131 +171,154 @@

     #@-node:cmd_init
     #@+node:cmd_start
+    def cmd_start(self, *args):

-    print "starting freedisk service..."
-    fs = freenetfs.FreenetFS(
-            conf.mountpoint,
-            fcpHost=conf.fcpHost,
-            fcpPort=conf.fcpPort,
-            verbosity=conf.fcpVerbosity,
-            debug=debug,
-            multithreaded=multithreaded,
-            )
-    
-    # spawn a process to run it
-    if os.fork() == 0:
-        print "Mounting freenet fs at %s" % conf.mountpoint
-        fs.run()
-    else:
-        # parent process
-        keyDir = os.path.join(conf.mountpoint, "keys")
-        print "Waiting for disk to come up..."
-        while not os.path.isdir(keyDir):
-            time.sleep(1)
-        disks = conf.getDisks()
-    
-        if disks:
-            print "Freenetfs now mounted, adding existing disks..."
+        print "starting freedisk service..."
+        fs = freenetfs.FreenetFS(
+                conf.mountpoint,
+                fcpHost=conf.fcpHost,
+                fcpPort=conf.fcpPort,
+                verbosity=conf.fcpVerbosity,
+                debug=debug,
+                multithreaded=multithreaded,
+                )
+        
+        # spawn a process to run it
+        if os.fork() == 0:
+            print "Mounting freenet fs at %s" % conf.mountpoint
+            fs.run()
         else:
-            print "Freenetfs now mounted, no freedisks at present"
-    
-        for disk in disks:
-    
-            diskPath = os.path.join(conf.mountpoint, "usr", disk.name)
-    
-            # barf if a freedisk of that name is already mounted
-            if os.path.exists(diskPath):
-                usage("Freedisk %s seems to be already mounted" % disk.name)
-            
-            # mkdir to create the freedisk dir
-            os.mkdir(diskPath)
-    
-            pubKeyPath = os.path.join(diskPath, ".publickey")
-            privKeyPath = os.path.join(diskPath, ".privatekey")
-            passwdPath = os.path.join(diskPath, ".passwd")
-    
-            # wait for the pseudo-files to come into existence
-            while not os.path.isfile(privKeyPath):
-                time.sleep(0.1)
-    
-            # set the key and password
-            file(pubKeyPath, "w").write(disk.uri)
-            file(privKeyPath, "w").write(disk.privUri)
-            file(passwdPath, "w").write(disk.passwd)
-            
+            # parent process
+            keyDir = os.path.join(conf.mountpoint, "keys")
+            print "Waiting for disk to come up..."
+            while not os.path.isdir(keyDir):
+                time.sleep(1)
+            disks = conf.getDisks()
+        
+            if disks:
+                print "Freenetfs now mounted, adding existing disks..."
+            else:
+                print "Freenetfs now mounted, no freedisks at present"
+        
+            for disk in disks:
+        
+                diskPath = os.path.join(conf.mountpoint, "usr", disk.name)
+        
+                # barf if a freedisk of that name is already mounted
+                if os.path.exists(diskPath):
+                    usage("Freedisk %s seems to be already mounted" % 
disk.name)
+                
+                # mkdir to create the freedisk dir
+                os.mkdir(diskPath)
+        
+                pubKeyPath = os.path.join(diskPath, ".publickey")
+                privKeyPath = os.path.join(diskPath, ".privatekey")
+                passwdPath = os.path.join(diskPath, ".passwd")
+        
+                # wait for the pseudo-files to come into existence
+                while not os.path.isfile(privKeyPath):
+                    time.sleep(0.1)
+        
+                # set the key and password
+                file(pubKeyPath, "w").write(disk.uri)
+                file(privKeyPath, "w").write(disk.privUri)
+                file(passwdPath, "w").write(disk.passwd)
+                
+        
+    #@nonl
     #@-node:cmd_start
     #@+node:cmd_stop
-    os.system("umount %s" % conf.mountpoint)
+    def cmd_stop(self, *args):
+        """
+        Unmount the freenetfs
+        """
+        os.system("umount %s" % self.conf.mountpoint)

     #@-node:cmd_stop
     #@+node:cmd_new
-    #print "new: %s: NOT IMPLEMENTED" % diskname
+    def cmd_new(self, *args):
+        """
+        Creates a new freedisk with a random key
+        """
+        #print "new: %s: NOT IMPLEMENTED" % diskname
+        
+        conf = self.conf
+        diskname = self.diskname
+        diskPath = self.diskPath

-    if os.path.exists(diskPath):
-        usage("Freedisk %s seems to be already mounted" % diskname)
-    
-    # get a password if desired
-    passwd = getpasswd("Encrypt disk with password", True)
-    
-    # get a new private key
-    keyDir = os.path.join(conf.mountpoint, "keys")
-    if not os.path.isdir(keyDir):
-        print "No keys directory %s" % keyDir
-        print "Is your freenetfs mounted?"
-        usage("Freenetfs not mounted")
-    keyName = "freedisk_%s_%s" % (diskname, int(time.time()*1000000))
-    keyPath = os.path.join(keyDir, keyName)
-    
-    keys = file(keyPath).read().strip().split("\n")
-    pubKey, privKey = [k.split("/")[0].split("freenet:")[-1] for k in keys]
-    
-    # mkdir to create the freedisk dir
-    os.mkdir(diskPath)
-    
-    # wait for the pseudo-files to come into existence
-    while not os.path.isfile(privKeyPath):
-        time.sleep(0.1)
-    
-    #status("About to write to %s" % privKeyPath)
-    
-    file(pubKeyPath, "w").write(pubKey)
-    file(privKeyPath, "w").write(privKey)
-    file(passwdPath, "w").write(passwd)
-    
-    # and, of course, update config
-    conf.addDisk(diskname, pubKey, privKey, passwd)
-    
+        if os.path.exists(diskPath):
+            usage("Freedisk %s seems to be already mounted" % diskname)
+        
+        # get a password if desired
+        passwd = getpasswd("Encrypt disk with password", True)
+        
+        # get a new private key
+        keyDir = os.path.join(conf.mountpoint, "keys")
+        if not os.path.isdir(keyDir):
+            print "No keys directory %s" % keyDir
+            print "Is your freenetfs mounted?"
+            usage("Freenetfs not mounted")
+        keyName = "freedisk_%s_%s" % (diskname, int(time.time()*1000000))
+        keyPath = os.path.join(keyDir, keyName)
+        
+        keys = file(keyPath).read().strip().split("\n")
+        pubKey, privKey = [k.split("/")[0].split("freenet:")[-1] for k in keys]
+        
+        # mkdir to create the freedisk dir
+        os.mkdir(diskPath)
+        
+        # wait for the pseudo-files to come into existence
+        while not os.path.isfile(privKeyPath):
+            time.sleep(0.1)
+        
+        #status("About to write to %s" % privKeyPath)
+        
+        file(self.pubKeyPath, "w").write(pubKey)
+        file(self.privKeyPath, "w").write(privKey)
+        file(self.passwdPath, "w").write(passwd)
+        
+        # and, of course, update config
+        conf.addDisk(diskname, pubKey, privKey, passwd)
+        
+        
+    #@nonl
     #@-node:cmd_new
     #@+node:cmd_add
-    # get uri
-    if nargs < 3:
-        usage("add: Missing URI")
-    uri = args[2]
+    def cmd_add(self, *args):

-    #print "add: %s: NOT IMPLEMENTED" % diskname
+        nargs = len(args)

-    # barf if a freedisk of that name is already mounted
-    if os.path.exists(diskPath):
-        usage("Freedisk %s seems to be already mounted" % diskname)
+        # get uri
+        if nargs < 3:
+            usage("add: Missing URI")
+        uri = args[1]

-    # mkdir to create the freedisk dir
-    os.mkdir(diskPath)
-    
-    # wait for the pseudo-files to come into existence
-    while not os.path.isfile(privKeyPath):
-        time.sleep(0.1)
-    
-    # set the keys
-    
-    if fcp.node.uriIsPrivate(uri):
-        path = privKeyPath
-    else:
-        path = pubKeyPath
-    f = file(path, "w")
-    f.write(uri)
-    f.flush()
-    f.close()
-    
+        #print "add: %s: NOT IMPLEMENTED" % diskname
+        
+        # barf if a freedisk of that name is already mounted
+        if os.path.exists(self.diskPath):
+            usage("Freedisk %s seems to be already mounted" % diskname)
+        
+        # mkdir to create the freedisk dir
+        os.mkdir(self.diskPath)
+        
+        # wait for the pseudo-files to come into existence
+        while not os.path.isfile(self.privKeyPath):
+            time.sleep(0.1)
+        
+        # set the keys
+        
+        if fcp.node.uriIsPrivate(uri):
+            path = privKeyPath
+        else:
+            path = pubKeyPath
+        f = file(path, "w")
+        f.write(uri)
+        f.flush()
+        f.close()
+        
+        
+    #@nonl
     #@-node:cmd_add
     #@+node:cmd_del
     disk = conf.getDisk(diskname)
@@ -754,8 +777,10 @@

     #@    <<execute command>>
     #@+node:<<execute command>>
-    mgr = FreediskMgr(**opts)
+    mgr = FreediskMgr(*args, **opts)

+    mgr.run()
+    
     #@-node:<<execute command>>
     #@nl



Reply via email to