home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / xbmc-9.11.exe / system / python / spyce / spyceXbmc.py < prev    next >
Encoding:
Python Source  |  2009-12-23  |  813 b   |  26 lines

  1. import sys, os
  2. sys.path.append(sys.executable + '\\spyce')
  3. from StringIO import StringIO
  4. import spyce, spyceCmd, string
  5.  
  6. def ParseFile(file, env):
  7.     output = StringIO()
  8.     input = StringIO(env['QUERY_STRING'])
  9.     env['REQUEST_URI'] = "/" + string.replace(string.lstrip(file, "Q:\\web"), "\\", "/")
  10.     SPYCE_HOME = os.path.abspath(os.path.dirname(sys.modules['spyceXbmc'].__file__))
  11.     request = spyceCmd.spyceCmdlineRequest(input, env, file)
  12.     response = spyceCmd.spyceCmdlineResponse(output, sys.stderr, 1)
  13.     result = spyce.spyceFileHandler(request, response, file)
  14.     response.flush()
  15.     result = output.getvalue()
  16.     response.close()
  17.     return result
  18.  
  19. if __name__ == '__main__':
  20.     file = 'docs\\examples\\hello.spy'
  21.     if os.access(file, os.F_OK):
  22.         print(ParseFile(file))
  23.     else:
  24.         print('file not found')
  25.  
  26.