def remain(argv): # sys.stderr.write('<chameleon script activated: %r>\n' % (argv)) cmdname = naturalName(argv[0]) binpath = findscript(cmdname) if binpath is None: sys.stderr.write('<chameleon could not change form!>\n') os._exit(254) newargz = [binpath] + argv[1:] # sys.stderr.write('<chameleon changing form: %r>\n' % (newargz,)) if os.name == 'nt': newargz.insert(0, sys.executable) binpath = sys.executable newargz = map(branchmgr._cmdLineQuote, newargz) binpath = branchmgr._cmdLineQuote(binpath) wincmd = ' '.join(newargz[1:]) import msvcrt try: # There is probably a better 'are we running in a GUI, ie, is # os.system going to be completely broken' test, but I have no idea # what it is. osfh = msvcrt.get_osfhandle(0) except IOError: try: import win32pipe except ImportError: print "Non-console I/O is broken on win32" print "Workaround requires pywin32" print ("http://sourceforge.net/project/showfiles.php?" "group_id=78018") os._exit(2) else: ipipe, opipe = win32pipe.popen4(' '.join(newargz), 't') ipipe.close() while 1: byte = opipe.read(1) if not byte: break sys.stdout.write(byte) sys.stdout.flush() else: signal.signal(signal.SIGINT, nostop) # ^C on Windows suuuuuuuucks exstat = os.system(' '.join(newargz)) os._exit(exstat) else: os.execv(binpath, newargz)
def ConvertFile(self, filename, outformat="html"): oodir = settings.AppSettings["OpenOffice"] if oodir != "": oldcwd = os.getcwd() os.chdir(settings.AppDir) import win32api #get the output and send it to a file command = "ooconvert.bat \"" + win32api.GetShortPathName(oodir) + "\" \"" + win32api.GetShortPathName(filename) + "\"" import win32pipe myin, mystream = win32pipe.popen4(command) filetext = mystream.read() mystream.close() handle, htmlfile = tempfile.mkstemp() os.close(handle) myfile = open(htmlfile, "wb") myfile.write(filetext) myfile.close() os.chdir(oldcwd) return htmlfile, "html" return ""
PASSTIME = config.getint('general', 'password_timeout') motd = config.get('general', 'motd').split('|') atlogin = config.get('general', 'atlogin').split(' ') if atlogin[0] == '': del(atlogin[0]) except: logmsg('Failed setting configuration, exiting...') exit() logmsg('Running the server executable...') server_args = ["java", "-Xmx%s" % (HEAPMEM_MAX), "-Xms%s" % (HEAPMEM_MIN), "-jar", SERVER, "nogui"] if os.name == 'nt': import win32pipe (stdin, stdout) = win32pipe.popen4(" ".join(server_args)) else: server = Popen(server_args, stdout = PIPE, stdin = PIPE, stderr = PIPE) outputs = [server.stderr, server.stdout, sys.stdin] stdin = server.stdin # Proudly scraped off http://copy.bplaced.net/mc/ids.php blocks = dict({ "stone": 1, "rock": 1, "grass": 2, "dirt": 3, "cobblestone": 4, "wood": 5, "sapling": 6, "bedrock": 7, "water": 8, "stillwater": 9, "lava": 10, "stilllava": 11, "sand": 12, "gravel": 13, "goldore": 14, "ironore": 15, "coalore": 16, "tree": 17, "leaves": 18, "sponge": 19, "glass": 20,
def run(self): import win32pipe print 'Executing',self.command_line (stdin,stdout)=win32pipe.popen4(self.command_line,"t") print 'End of Command'
import test_filter_genshi for method in dir(test_filter_genshi.GenshiFilterTests): if method.startswith('test_'): break else: delattr(ApplyTest,'test_apply_genshi_fancy') try: import libxml2 except ImportError: delattr(ApplyTest,'test_apply_filter_mememe') try: import win32pipe (stdin,stdout) = win32pipe.popen4('xsltproc -V', 't') stdin.close() stdout.read() try: exitcode = stdout.close() except IOError: exitcode = -1 except: import commands (exitstatus,output) = commands.getstatusoutput('xsltproc -V') exitcode = ((exitstatus>>8) & 0xFF) if exitcode: logger.warn("xsltproc is not available => can't test XSLT templates") for method in dir(ApplyTest): if method.startswith('test_'): delattr(ApplyTest,method)
if atlogin[0] == '': del (atlogin[0]) except: logmsg('Failed setting configuration, exiting...') exit() logmsg('Running the server executable...') server_args = [ "java", "-Xmx%s" % (HEAPMEM_MAX), "-Xms%s" % (HEAPMEM_MIN), "-jar", SERVER, "nogui" ] if os.name == 'nt': import win32pipe (stdin, stdout) = win32pipe.popen4(" ".join(server_args)) else: server = Popen(server_args, stdout=PIPE, stdin=PIPE, stderr=PIPE) outputs = [server.stderr, server.stdout, sys.stdin] stdin = server.stdin # Proudly scraped off http://copy.bplaced.net/mc/ids.php blocks = dict({ "stone": 1, "rock": 1, "grass": 2, "dirt": 3, "cobblestone": 4, "wood": 5, "sapling": 6,
import test_filter_genshi for method in dir(test_filter_genshi.GenshiFilterTests): if method.startswith('test_'): break else: delattr(ApplyTest, 'test_apply_genshi_fancy') try: import libxml2 except ImportError: delattr(ApplyTest, 'test_apply_filter_mememe') try: import win32pipe (stdin, stdout) = win32pipe.popen4('xsltproc -V', 't') stdin.close() stdout.read() try: exitcode = stdout.close() except IOError: exitcode = -1 except: import commands (exitstatus, output) = commands.getstatusoutput('xsltproc -V') exitcode = ((exitstatus >> 8) & 0xFF) if exitcode: logger.warn("xsltproc is not available => can't test XSLT templates") for method in dir(ApplyTest): if method.startswith('test_'): delattr(ApplyTest, method)
def getShellOutput(cmd): (stdin, stdout) = win32pipe.popen4(cmd, 't') data = stdout.read() rc = stdout.close() return rc, data