home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_317 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.6 KB  |  57 lines

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