Skip to content

fixing hardcoded path to configuration in rpcserver.py #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions multimechanize/rpcserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@



def launch_rpc_server(bind_addr, port, project_name, run_callback):
def launch_rpc_server(bind_addr, port, project_name, run_callback, projects_dir='projects'):
server = SimpleXMLRPCServer.SimpleXMLRPCServer((bind_addr, port), logRequests=False)
server.register_instance(RemoteControl(project_name, run_callback))
server.register_instance(RemoteControl(project_name, run_callback, projects_dir))
server.register_introspection_functions()
print '\nMulti-Mechanize: %s listening on port %i' % (bind_addr, port)
print 'waiting for xml-rpc commands...\n'
Expand All @@ -27,11 +27,12 @@ def launch_rpc_server(bind_addr, port, project_name, run_callback):


class RemoteControl(object):
def __init__(self, project_name, run_callback):
def __init__(self, project_name, run_callback, projects_dir='projects'):
self.project_name = project_name
self.run_callback = run_callback
self.test_running = False
self.output_dir = None
self.projects_dir = projects_dir

def run_test(self):
if self.test_running:
Expand All @@ -44,12 +45,18 @@ def check_test_running(self):
return self.test_running

def update_config(self, config):
with open('projects/%s/config.cfg' % self.project_name, 'w') as f:
with open('%(projects_dir)s/%(project)s/config.cfg' % {
'project': self.project_name,
'projects_dir': self.projects_dir
} , 'w') as f:
f.write(config)
return True

def get_config(self):
with open('projects/%s/config.cfg' % self.project_name, 'r') as f:
with open('%(projects_dir)s/%(project)s/config.cfg' % {
'project': self.project_name,
'projects_dir': self.projects_dir
} , 'r') as f:
return f.read()

def get_project_name(self):
Expand Down
6 changes: 5 additions & 1 deletion multimechanize/utilities/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ def main():
rerun_results(project_name, cmd_opts, cmd_opts.results_dir)
elif cmd_opts.port:
import multimechanize.rpcserver
multimechanize.rpcserver.launch_rpc_server(cmd_opts.bind_addr, cmd_opts.port, project_name, run_test)
multimechanize.rpcserver.launch_rpc_server(cmd_opts.bind_addr,
cmd_opts.port,
project_name,
run_test,
cmd_opts.projects_dir)
else:
run_test(project_name, cmd_opts)
return
Expand Down