Mercurial > pylearn
changeset 546:cb8eabe7d941
merged
author | desjagui@atchoum.iro.umontreal.ca |
---|---|
date | Tue, 18 Nov 2008 19:42:12 -0500 |
parents | 24dfe316e79a (diff) de6de7c2c54b (current diff) |
children | d3791c59f36e 0ac4927e9d97 |
files | |
diffstat | 1 files changed, 25 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/pylearn/dbdict/dbdict_run_sql.py Mon Nov 17 20:05:31 2008 -0500 +++ b/pylearn/dbdict/dbdict_run_sql.py Tue Nov 18 19:42:12 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