# HG changeset patch # User James Bergstra # Date 1227201496 18000 # Node ID d3791c59f36edcb985e7c46d915a32fac67e3a09 # Parent 91735dbde209c6ddb55b32377d236182470d6587# Parent cb8eabe7d941688473a72325b9842e3adbdb7e99 merged diff -r 91735dbde209 -r d3791c59f36e pylearn/dbdict/dbdict_run_sql.py --- 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: ":", 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