用python开始一天工作
1、第一次运行run1pm.py

2、第二次运行run1pm.py 会判断是否打开过

3、退出run1pm.py quit

4、第二次运行退出run1pm.py quit提示下面的信息 vagrant is not running,doesnot need e旌忭檀挢xit docker is not running,doesnot need exit notepad is not running,doesnot need exit haroopad is not running,doesnot need exit 请按任意键继续. . .

5、run1pm.py全部源码```python#!D:\appsoft\python\python.exe# -* 幻腾寂埒- coding: UTF-8 -* -import osimport sysimport time# ==============================================# 启动:# 1)run1pmEn.py# 退出:# 1) run1pmEn.py quit # ==============================================#_tARG1='start' # start quitif len(sys.argv)>1 and sys.argv[1]=='quit': _tARG1=sys.argv[1]# 使用方法 run1pmEn.py start 或run1pmEn.py quit# print(type(sys.argv),len(sys.argv),sys.argv[0],sys.argv[1])#for arg in sys.argv:# _tARG1=arg# print(arg)GAppdic={}# 定义变量begin ########################################################### notepad,docker,vagrant,haroopad# 1)启动应用 执行命令的方式# 2)退出 taskkill /im notepad++.exe 不用强制/f /im GAppdic['wiz']={'start':'start "" "E:\\test\\WizNote\\Wiz.exe"','quit':''}GAppdic['notepad']={'start':'start "" "D:\\greensoft\\npp.6.6.7.bin\\notepad++.exe"','quit':'taskkill /im notepad++.exe'}GAppdic['docker']={'start':'boot2docker start','quit':'boot2docker poweroff'}GAppdic['vagrant']={'start':'cd E:\\Vmdocker\\work\\yii && E: && vagrant up','quit':'cd E:\\Vmdocker\\work\\yii && E: && vagrant halt'}GAppdic['haroopad']={'start':'start "" "C:\\Users\\Administrator\\AppData\\Roaming\\Haroo Studio\\Haroopad\\haroopad.exe"','quit':'taskkill /im haroopad.exe'}# 定义变量end ########################################################## # 启动返回1 为启动返回0def CheckStatus(app): checkCMDSTR='' if app=='vagrant': # 判断vagrant checkCMDSTR='vagrant global-status |findstr /C:"virtualbox running E:/Vmdocker/work/yii"' elif app=='docker': checkCMDSTR='boot2docker status|findstr /C:"running"' # 判断docker是否启动 elif app=='notepad': checkCMDSTR='tasklist |findstr /C:"notepad++"' elif app=='haroopad': checkCMDSTR='tasklist |findstr /C:"haroopad"' elif app=='wiz': checkCMDSTR='tasklist |findstr /C:"Wiz.exe"' else: checkCMDSTR='' if checkCMDSTR!='': fdp=os.popen(checkCMDSTR) fdp_out=fdp.readline() fdp_out=fdp_out.replace("\n", "",1) # print("fdp_out",fdp_out) if fdp_out!="": return 1 else: return 0 else: return 0 #os.system #统一使用这个#os.popen 无法启动多命令,for appname in GAppdic: if _tARG1=='start': print(appname) if CheckStatus(appname) == 1: print(' is running') else: # os.system # popen 无法启动vagrant os.system(GAppdic[appname]['start']) # 暂停一秒 time.sleep(1) print(' is opened!') elif _tARG1=='quit': # popen 无法结束vagrant if GAppdic[appname]['quit']!='': if CheckStatus(appname)==1: os.system(GAppdic[appname]['quit']) else: print(appname+' is not running,doesnot need exit') else: if CheckStatus(appname)==1: print('+++++++++ please quit',appname,' by yourself +++++++++ '); #print(fdp.read()) else: print('not exist args') # 暂停os.system("pause")#2. 接收一个输入# raw_input('Press any key and Enter to continue ~!')```

