python调dotnet

import clr
import time
import os
import sys
os.system("title job "+sys.argv[1])
clr.AddReference('library')
from library import *
method=Sync.Instance.GetType().GetMethod(sys.argv[1])
last=0
while True:
    diff=time.time()-last
    if diff<300:
        time.sleep(300-diff)
    last=time.time()
    print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
    try:
        method.Invoke(Sync.Instance,None)
    except Exception as ex:
        print(ex.InnerException if(hasattr(ex,"InnerException") and ex.InnerException!=None) else ex)
        time.sleep(5)
        last=0

---------------------------------
jobs=["commandline"]
for v in jobs:
    print(os.system(v))

猜你喜欢

转载自blog.csdn.net/slwsss/article/details/99468519