Skip to content

Instantly share code, notes, and snippets.

@emctoo
Created May 23, 2012 13:59
Show Gist options
  • Save emctoo/2775379 to your computer and use it in GitHub Desktop.
Save emctoo/2775379 to your computer and use it in GitHub Desktop.
Windows 下用于自动化工作的Python脚本
#! /usr/bin/env python
import os, shutil
def remove_files_dirs(dir = '.'):
''' remove all files and dirs in cwd '''
print "Current work dir: " + os.getcwd()
judge = raw_input("remove all?[Y/n]")
if judge == 'n':
exit()
all = os.listdir(dir)
for item in all:
if item == '..' or item == '.':
continue
elif os.path.isdir(item) :
print 'remove [d] ' + item
shutil.rmtree(item)
elif os.path.isfile(item) :
print 'remove [f] ' + item
os.remove(item)
return
os.chdir("build")
print os.getcwd()
remove_files_dirs(".")
commands = [
'cmake -G \"NMake Makefiles\" ..',
'nmake',
# 'ls -al',
'simple.exe'
]
for item in commands:
os.system(item)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment