##// END OF EJS Templates
Jorgen Stenarson's patch (minor mods) to support network shares under win32.
fperez -
r66:ea1a07bf
parent child
Show More
@@ -5,7 +5,7 General purpose utilities.
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
6 these things are also convenient when working at the command line.
6 these things are also convenient when working at the command line.
7
7
8 $Id: genutils.py 971 2005-12-29 18:30:45Z fperez $"""
8 $Id: genutils.py 972 2005-12-29 18:45:19Z fperez $"""
9
9
10 #*****************************************************************************
10 #*****************************************************************************
11 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
11 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
@@ -308,6 +308,10 def system(cmd,verbose=0,debug=0,header=''):
308 if not debug: stat = os.system(cmd)
308 if not debug: stat = os.system(cmd)
309 return stat
309 return stat
310
310
311 # This function is used by ipython in a lot of places to make system calls.
312 # We need it to be slightly different under win32, due to the vagaries of
313 # 'network shares'. A win32 override is below.
314
311 def shell(cmd,verbose=0,debug=0,header=''):
315 def shell(cmd,verbose=0,debug=0,header=''):
312 """Execute a command in the system shell, always return None.
316 """Execute a command in the system shell, always return None.
313
317
@@ -331,6 +335,27 def shell(cmd,verbose=0,debug=0,header=''):
331 if not debug:
335 if not debug:
332 os.system(cmd)
336 os.system(cmd)
333
337
338 # override shell() for win32 to deal with network shares
339 if os.name in ('nt','dos'):
340
341 shell_ori = shell
342
343 def shell(cmd,verbose=0,debug=0,header=''):
344 if os.getcwd().startswith(r"\\"):
345 path = os.getcwd()
346 # change to c drive (cannot be on UNC-share when issuing os.system,
347 # as cmd.exe cannot handle UNC addresses)
348 os.chdir("c:")
349 # issue pushd to the UNC-share and then run the command
350 try:
351 shell_ori('"pushd %s&&"'%path+cmd,verbose,debug,header)
352 finally:
353 os.chdir(path)
354 else:
355 shell_ori('"pushd %s&&"'%path+cmd,verbose,debug,header)
356
357 shell.__doc__ = shell_ori.__doc__
358
334 def getoutput(cmd,verbose=0,debug=0,header='',split=0):
359 def getoutput(cmd,verbose=0,debug=0,header='',split=0):
335 """Dummy substitute for perl's backquotes.
360 """Dummy substitute for perl's backquotes.
336
361
@@ -1,5 +1,8
1 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
2
2
3 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
4 (minor mods) to support network shares under win32.
5
3 * IPython/winconsole.py (get_console_size): add new winconsole
6 * IPython/winconsole.py (get_console_size): add new winconsole
4 module and fixes to page_dumb() to improve its behavior under
7 module and fixes to page_dumb() to improve its behavior under
5 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
8 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
General Comments 0
You need to be logged in to leave comments. Login now