After searching the site-packages\spyderlib for the %run keyword, I found a method (in site-packages\spyderlib\plugins\ipythonconsole.py ) that builds the %run command:
def run_script_in_current_client(self, filename, wdir, args, debug): """Run script in current client, if any""" norm = lambda text: remove_backslashes(to_text_string(text)) client = self.get_current_client() if client is not None: # Internal kernels, use runfile if client.kernel_widget_id is not None: line = "%s('%s'" % ('debugfile' if debug else 'runfile', norm(filename)) if args: line += ", args='%s'" % norm(args) if wdir: line += ", wdir='%s'" % norm(wdir) line += ")" else: # External kernels, use %run line = "%run " if debug: line += "-d " line += "\"%s\"" % to_text_string(filename) if args: line += " %s" % norm(args) self.execute_python_code(line) self.visibility_changed(True) self.raise_() else: #XXX: not sure it can really happen QMessageBox.warning(self, _('Warning'), _("No IPython console is currently available to run <b>%s</b>." "<br><br>Please open a new one and try again." ) % osp.basename(filename), QMessageBox.Ok)
I added the following code to convert paths after else: # External kernels, use %run
# ----added to remap local dir to remote dir------- localpath = "Z:\wk" remotepath = "/mnt/sdb1/wk" if localpath in filename:
now it runs the file on the remote computer when I press F5. I am on Spyder 2.3.9 with samba sharing to z: drive.
source share