home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Calibre / calibre-0.8.18.msi / file_262 / commands.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-09-09  |  1.6 KB  |  51 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.7)
  3.  
  4. from warnings import warnpy3k
  5. warnpy3k('the commands module has been removed in Python 3.0; use the subprocess module instead', stacklevel = 2)
  6. del warnpy3k
  7. __all__ = [
  8.     'getstatusoutput',
  9.     'getoutput',
  10.     'getstatus']
  11.  
  12. def getstatus(file):
  13.     import warnings
  14.     warnings.warn('commands.getstatus() is deprecated', DeprecationWarning, 2)
  15.     return getoutput('ls -ld' + mkarg(file))
  16.  
  17.  
  18. def getoutput(cmd):
  19.     return getstatusoutput(cmd)[1]
  20.  
  21.  
  22. def getstatusoutput(cmd):
  23.     import os
  24.     pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
  25.     text = pipe.read()
  26.     sts = pipe.close()
  27.     if sts is None:
  28.         sts = 0
  29.     if text[-1:] == '\n':
  30.         text = text[:-1]
  31.     return (sts, text)
  32.  
  33.  
  34. def mk2arg(head, x):
  35.     import os
  36.     return mkarg(os.path.join(head, x))
  37.  
  38.  
  39. def mkarg(x):
  40.     if "'" not in x:
  41.         return " '" + x + "'"
  42.     s = None
  43.     for c in x:
  44.         if c in '\\$"`':
  45.             s = s + '\\'
  46.         s = s + c
  47.     
  48.     s = s + '"'
  49.     return s
  50.  
  51.