Skip to content

Instantly share code, notes, and snippets.

@larrycai
Created September 21, 2010 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larrycai/589219 to your computer and use it in GitHub Desktop.
Save larrycai/589219 to your computer and use it in GitHub Desktop.
cross platform execution in python
# call markdown to convert markdown -> html in memory
def mkd2html(inFilename):
#
# and there are different ways to handle windows and unix
# also subprocess.check_output exist in python27 only.
#
cmd = []
# mostly msysgit is used, cygwin, it is win32 platform
if sys.platform == "win32":
# i may need to check cygwin as well
mkdownrealpath = os.path.expanduser(cmdmarkdown)
cmd = ["c:\\python27\\python.exe",mkdownrealpath]
else: # unix
cmd = [cmdmarkdownSuSE]
cmd.append(inFilename)
output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
html = output.splitlines()
return html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment