# HG changeset patch # User desjagui@atchoum.iro.umontreal.ca # Date 1227054716 18000 # Node ID 24dfe316e79adbcc2858ed5fe466e5b928a916ef # Parent 5b4ccbf022c87d977c23850f9d56d8532fd9b67d (James) fixed issues when running locally and rsync command diff -r 5b4ccbf022c8 -r 24dfe316e79a pylearn/dbdict/dbdict_run_sql.py --- a/pylearn/dbdict/dbdict_run_sql.py Thu Nov 13 18:40:45 2008 -0500 +++ b/pylearn/dbdict/dbdict_run_sql.py Tue Nov 18 19:31:56 2008 -0500 @@ -291,16 +291,20 @@ :returns: ":", 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