[Assorted-commits] SF.net SVN: assorted:[951] sharing-gateway/trunk/src
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-08-28 07:54:30
|
Revision: 951 http://assorted.svn.sourceforge.net/assorted/?rev=951&view=rev Author: yangzhang Date: 2008-08-28 07:54:39 +0000 (Thu, 28 Aug 2008) Log Message: ----------- added indexing Modified Paths: -------------- sharing-gateway/trunk/src/gateway.py sharing-gateway/trunk/src/index.pandoc Modified: sharing-gateway/trunk/src/gateway.py =================================================================== --- sharing-gateway/trunk/src/gateway.py 2008-08-28 07:30:00 UTC (rev 950) +++ sharing-gateway/trunk/src/gateway.py 2008-08-28 07:54:39 UTC (rev 951) @@ -9,7 +9,7 @@ from os import system from path import path from socket import gethostbyname -from subprocess import Popen +from subprocess import Popen, PIPE import yaml class my_exception( Exception ): pass @@ -19,6 +19,11 @@ if p.wait() != 0: raise my_exception( 'command failed with error code %s: %s' % ( p.returncode, cmd ) ) +def runout( cmd, f ): + p = Popen( cmd, stdout = f ) + if p.wait() != 0: + raise my_exception( 'command failed with error code %s: %s' % ( p.returncode, cmd ) ) + def main( argv ): parser = OptionParser( usage = '%prog [OPTIONS] start | stop' ) parser.add_option( '-c', '--config', @@ -29,6 +34,7 @@ cmd = args[-1] with file( opts.config ) as f: cfg = dicts2structs( yaml.load( f ) ) mountdir = path( cfg.gateway.mountdir ) + indexdir = path( cfg.gateway.indexdir ) if cmd == 'start': for s in cfg.shares: @@ -46,6 +52,16 @@ mountpt = mountdir / s.name run( [ 'sudo', 'umount', mountpt ] ) run( [ 'sudo', 'rmdir', mountpt ] ) + elif cmd == 'index': # requires super user + for s in cfg.shares: + print 'indexing', s.name + mountpt = mountdir / s.name + index = indexdir / s.name + try: + with file( index, 'w' ) as f: + runout( [ 'ls', '-lR', mountpt ], f ) + except: + pass else: raise my_exception( 'unknown command: %s' % cmd ) Modified: sharing-gateway/trunk/src/index.pandoc =================================================================== --- sharing-gateway/trunk/src/index.pandoc 2008-08-28 07:30:00 UTC (rev 950) +++ sharing-gateway/trunk/src/index.pandoc 2008-08-28 07:54:39 UTC (rev 951) @@ -7,4 +7,9 @@ [CA certificate]: http://zs.ath.cx/ca.crt -Then log in to <https://zs.ath.cx/gw/> using the login I provided you. +Then log in to the SSL-enabled site, <https://zs.ath.cx/gw/>, using the login I +provided you. + +Currently, we generate simple indexes so that you can search for files; these +are in <https://zs.ath.cx/gw/index/>. To browse/retrieve the actual files, go +to <https://zs.ath.cx/gw/raw/>. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |