- 論壇徽章:
- 4
|
俺剛用wx寫的
# --*-- encoding: UTF-8 --*--
import wx
import os
import wx.lib.dialogs
cmd_dbsvc = "C:\\win32\\dbsvc.exe"
cmd_dbsrv = "c:\win32\\dbsrv9.exe"
db_file = "C:\\Program Files\\Sybase\\SQL Anywhere 9\\asademo.db"
class InsertFrame(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, u"Bceng 服務(wù)管理器",
size=(380, 100),style=wx.SYSTEM_MENU |wx.CAPTION |wx.MINIMIZE_BOX |wx.CLOSE_BOX )
panel = wx.Panel(self)
bsvcReg = wx.Button(panel, label=u"注冊服務(wù)", pos=(10, 10),
size=(70, 50))
bsvcStart= wx.Button(panel, label = u"啟動服務(wù)", pos=(80,10),
size=(70,50) )
bsvcDel = wx.Button(panel, label = u"刪除服務(wù)", pos=(150,10),
size=(70,50))
bsvcStop= wx.Button(panel, label=u"停止服務(wù)", pos=(220,10),
size =(70,50))
bexit = wx.Button(panel, label = u"退出", pos =(290,10),
size=(70,50))
if os.path.exists(cmd_dbsvc) == False or os.path.exists(cmd_dbsrv) == False or os.path.exists(db_file) == False:
bsvcReg.Enable(False)
bsvcStart.Enable(False)
bsvcDel.Enable(False)
bsvcStop.Enable(False)
self.Bind(wx.EVT_BUTTON, self.OnCloseMe, bexit)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
self.Bind(wx.EVT_BUTTON, self.OnSvcReg, bsvcReg)
self.Bind(wx.EVT_BUTTON, self.OnSvcStop, bsvcStop)
self.Bind(wx.EVT_BUTTON, self.OnSvcDel, bsvcDel)
self.Bind(wx.EVT_BUTTON, self.OnSvcStart, bsvcStart)
def OnCloseMe(self, event):
self.Close(True)
def OnSvcReg(self, event):
# dbsvc -as -s auto -t network -w mynetworkserv "C:\Program Files\Sybase\SQL Anywhere 9\win32\dbsrv9.exe" -x tcpip -c 8m "C:\Program Files\Sybase\SQL Anywhere 9\sample.db"
rtn = os.popen( cmd_dbsvc + " -as -s auto -t network -w BCENGSVC " + cmd_dbsrv + " -x tcpip -c 8m " + '"'+db_file+ '"')
dlg = wx.lib.dialogs.scrolledMessageDialog(self, rtn.read(), u"提示")
dlg.ShowModal()
wx.MessageDialog(None,u"數(shù)據(jù)庫服務(wù)器注冊成功,請重新啟動系統(tǒng)",u"提示")
pass
def OnSvcStop(self, event):
dlg = wx.MessageDialog(None, u"確定要停止數(shù)據(jù)庫服務(wù)器嗎?",u"詢問", wx.OK|wx.CANCEL|wx.ICON_WARNING)
retCode = dlg.ShowModal()
if retCode == wx.ID_CANCEL:return
rtn = os.popen(cmd_dbsvc + " -x BCENGSVC" )
dlg = wx.lib.dialogs.scrolledMessageDialog(self, rtn.read(), u"提示")
dlg.ShowModal()
def OnSvcDel(self, event):
dlg = wx.MessageDialog(None,u"確定要刪除服務(wù)嗎?",u"警告",
wx.OK|wx.CANCEL|wx.ICON_WARNING )
retCode = dlg.ShowModal()
if retCode == wx.ID_OK:
rtn = os.popen(cmd_dbsvc +" -y -d BCENGSVC")
dlg = wx.lib.dialogs.scrolledMessageDialog(self, rtn.read(), u"提示")
dlg.ShowModal()
if retCode == wx.ID_CANCEL:
print 'Cancel'
def OnSvcStart(self, event):
rtn = os.popen(cmd_dbsvc + " -u BCENGSVC")
dlg = wx.lib.dialogs.scrolledMessageDialog(self, rtn.read(), u"提示")
dlg.ShowModal()
def OnCloseWindow(self, event):
self.Destroy()
if __name__ == '__main__':
# cmd_dbsvc = os.path.dirname(__file__)+os.sep + "dbsvc.exe"
# tmp = os.popen(dbsvc)
cmd_dbsvc = os.getcwd() + os.sep + "DB" + os.sep + "dbsvc.exe"
cmd_dbsrv = os.getcwd() + os.sep + "DB" + os.sep + "dbsrv9.exe"
db_file = os.getcwd() + os.sep + "DB" + os.sep + "BCENG.db"
app = wx.PySimpleApp()
frame = InsertFrame(parent=None, id=-1)
frame.Show()
app.MainLoop() |
|