Mercurial > pylearn
changeset 548:d3791c59f36e
merged
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Thu, 20 Nov 2008 12:18:16 -0500 |
parents | 91735dbde209 (current diff) cb8eabe7d941 (diff) |
children | 16894d38ce48 |
files | |
diffstat | 1 files changed, 25 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/pylearn/dbdict/dbdict_run_sql.py Thu Nov 20 12:17:56 2008 -0500 +++ b/pylearn/dbdict/dbdict_run_sql.py Thu Nov 20 12:18:16 2008 -0500 @@ -291,16 +291,20 @@ :returns: "<host>:<path>", of the sort used by ssh and rsync. """ - path = os.path.join( - ':'.join([self.host, self.path]), - self.dbname, - self.tablename, - self.id) + if self.host: + path = os.path.join( + ':'.join([self.host, self.path]), + self.dbname, + self.tablename, + self.id) + else: + path = os.path.join(self.path, + self.dbname, self.tablename, self.id) if direction == 'push': - rsync_cmd = 'rsync -r * "%s"' % path + rsync_cmd = 'rsync -a * "%s/"' % path elif direction == 'pull': - rsync_cmd = 'rsync -r "%s/*" .' % path + rsync_cmd = 'rsync -a "%s/" .' % path else: raise Exception('invalid direction', direction) @@ -315,13 +319,18 @@ return self.rsync('push') def touch(self): - host = self.host path = os.path.join(self.path, self.dbname, self.tablename, self.id) - ssh_cmd = ('ssh %(host)s "mkdir -p \'%(path)s\' && cd \'%(path)s\' ' - '&& touch stdout stderr && mkdir -p workdir"' % locals()) - ssh_rval = os.system(ssh_cmd) - if 0 != ssh_rval: - raise Exception('ssh failure', (ssh_rval, ssh_cmd)) + if self.host: + host = self.host + touch_cmd = ('ssh %(host)s "mkdir -p \'%(path)s\' && cd \'%(path)s\' ' + '&& touch stdout stderr && mkdir workdir"' % locals()) + else: + touch_cmd = ("mkdir -p '%(path)s' && cd '%(path)s' " + '&& touch stdout stderr && mkdir workdir' % locals()) + print "ECHO", touch_cmd + touch_rval = os.system(touch_cmd) + if 0 != touch_rval: + raise Exception('touch failure', (touch_rval, touch_cmd)) def delete(self): #something like ssh %s 'rm -Rf %s' should work, but it's pretty scary... @@ -341,6 +350,9 @@ except: exproot = os.getcwd() + if not exproot.startswith('/'): + exproot = os.path.join(os.getcwd(), exproot) + #TODO: THIS IS A GOOD IDEA RIGHT? # It makes module-lookup work based on cwd-relative paths # But possibly has really annoying side effects? Is there a cleaner