--- a/goa/tools/laxctl.py Thu May 14 10:24:56 2009 +0200
+++ b/goa/tools/laxctl.py Thu May 14 11:38:40 2009 +0200
@@ -23,7 +23,7 @@
def initialize_vregistry(applroot):
# apply monkey patches first
- from cubicweb.goa import do_monkey_patch
+ from cubicweb.goa import do_monkey_patch
do_monkey_patch()
from cubicweb.goa.goavreg import GAERegistry
from cubicweb.goa.goaconfig import GAEConfiguration
@@ -32,21 +32,21 @@
vreg = GAERegistry(config)
vreg.set_schema(config.load_schema())
return vreg
-
+
def alistdir(directory):
return [osp.join(directory, f) for f in os.listdir(directory)]
class LaxCommand(Command):
"""base command class for all lax commands
- creates vreg, schema and calls
+ creates vreg, schema and calls
"""
min_args = max_args = 0
def run(self, args):
self.vreg = initialize_vregistry(APPLROOT)
self._run(args)
-
+
class GenerateSchemaCommand(LaxCommand):
"""generates the schema's png file"""
@@ -54,7 +54,7 @@
def _run(self, args):
assert not args, 'no argument expected'
- from yams import schema2dot
+ from yams import schema2dot
schema = self.vreg.schema
skip_rels = ('owned_by', 'created_by', 'identity', 'is', 'is_instance_of')
path = osp.join(APPLROOT, 'data', 'schema.png')
@@ -107,7 +107,7 @@
class GetSessionIdHandler(urllib2.HTTPRedirectHandler):
def __init__(self, config):
self.config = config
-
+
def http_error_303(self, req, fp, code, msg, headers):
cookie = SimpleCookie(headers['Set-Cookie'])
sessionid = cookie['__session'].value
@@ -115,7 +115,7 @@
setattr(self.config, 'cookie', '__session=' + sessionid)
return 1 # on exception should be raised
-
+
class URLCommand(LaxCommand):
"""abstract class for commands doing stuff by accessing the web application
"""
@@ -138,7 +138,7 @@
'help': 'user password instead of giving raw cookie string (require '
'lax based authentication).'}),
)
-
+
def _run(self, args):
baseurl = args[0]
if not baseurl.startswith('http'):
@@ -154,9 +154,9 @@
urllib2.install_opener(opener)
data = urlencode(dict(__login=self.config.user,
__password=self.config.password))
- self.open_url(urllib2.Request(baseurl, data))
+ self.open_url(urllib2.Request(baseurl, data))
opener = urllib2.build_opener(NoRedirectHandler())
- urllib2.install_opener(opener)
+ urllib2.install_opener(opener)
self.do_base_url(baseurl)
def build_req(self, url):
@@ -164,7 +164,7 @@
if self.config.cookie:
req.headers['Cookie'] = self.config.cookie
return req
-
+
def open_url(self, req):
try:
return urllib2.urlopen(req)
@@ -194,11 +194,11 @@
msg = remove_html_tags(match.group(1))
print msg
return msg
-
+
def do_base_url(self, baseurl):
raise NotImplementedError()
-
+
class DSInitCommand(URLCommand):
"""initialize the datastore"""
name = 'db-init'
@@ -210,7 +210,7 @@
'help': 'number of seconds to wait between each request to avoid '
'going out of quota.'}),
)
-
+
def do_base_url(self, baseurl):
req = self.build_req(baseurl + '?vid=contentinit')
while True:
@@ -240,8 +240,8 @@
req = self.build_req(baseurl + '?vid=cleansessions')
data = self.open_url(req)
self.extract_message(data)
-
-
+
+
register_commands([GenerateSchemaCommand,
PopulateDataDirCommand,
DSInitCommand,
@@ -250,6 +250,6 @@
def run():
main_run(sys.argv[1:])
-
+
if __name__ == '__main__':
run()