def start():
    myGui = Tk(className="服务管理")
    myGui.withdraw()
    myGui.resizable(width=False, height=False)

    GREEN = PhotoImage(file=LoadConfig.loadConfig("pic_address", "GreenPicAddress"))
    RED = PhotoImage(file=LoadConfig.loadConfig("pic_address", "RedPicAddress"))
    YELLOW = PhotoImage(file=LoadConfig.loadConfig("pic_address", "YellowPicAddress"))
    LOGO = PhotoImage(file=LoadConfig.loadConfig("pic_address", "LogoPicAddress"))
    MESSAGE = PhotoImage(file=LoadConfig.loadConfig("pic_address", "MessagePicAddress"))

    ServiceNameList = LoadConfig.loadNameList()
    LogListAddress = LoadConfig.loadConfig("file_address", "LogListAddress")
    InstallAddress = LoadConfig.loadConfig("file_address", "SetupAddress")

    # for count in range(int(len(ServiceNameList) / 3)):
    #     printComp.printMenuButton(myGui, ServiceNameList[int(count * 3 + 1)], ServiceNameList[int(count * 3)], count, 1,
    #                               LogListAddress, ServiceNameList[int(count * 3 + 2)], InstallAddress)

    printComp.printLabel(myGui, BLANK_4, int(len(ServiceNameList) / 3) + 1, 1, 1)
    printComp.printPNG(MESSAGE, int(len(ServiceNameList) / 3) + 2, 1, 100)
    printComp.printLabel(myGui, BLANK_4, int(len(ServiceNameList) / 3) + 3, 1, 1)

    printComp.printPNG(LOGO, int(len(ServiceNameList) / 3) + 4, 1, 1)
    printComp.printButton(myGui, START_ALL, ServiceNameList, int(len(ServiceNameList) / 3) + 4, 2, 1, LogListAddress)
    printComp.printButton(myGui, STOP_ALL, ServiceNameList, int(len(ServiceNameList) / 3) + 4, 3, 1, LogListAddress)
    printComp.printButton(myGui, LOG_LIST, None, int(len(ServiceNameList) / 3) + 4, 4, 1, LogListAddress)

    refreshStateThread = threading.Thread(target=ServicePackage.ReFreshStateThreading,
                                          args=(myGui, ServiceNameList,
                                                int(LoadConfig.loadConfig('time', 'StateReFreshTime')), GREEN, RED,
                                                YELLOW))
    refreshBtnMThread = threading.Thread(
        target=ServicePackage.ReFreshBtnMThreading, args=(myGui, ServiceNameList, LogListAddress, InstallAddress,
                                                          int(LoadConfig.loadConfig('time', 'ButtonReFreshTime'))))

    refreshStateThread.daemon = True
    refreshBtnMThread.daemon = True

    refreshStateThread.start()
    refreshBtnMThread.start()

    myGui.update_idletasks()

    width = 430
    SetX = (myGui.winfo_screenwidth() - width) / 2
    height = int(len(ServiceNameList)) * 26 / 3 + 133
    SetY = (myGui.winfo_screenheight() - height) / 2
    myGui.geometry("%dx%d+%d+%d" % (width, height, SetX, SetY))
    myGui.deiconify()

    myGui.mainloop()
示例#2
0
def main(argv):
    # 設定ファイル読み込み
    c = lc.LoadConfig()

    # 実際のスクレイピング処理
    L = get_hatebu_ranking(c)

    # Slackへ通知
    ss.send_slack(L, c)
示例#3
0
def main():
    global k_date, k_table

    if len(sys.argv) < 3:
        PrintInfo.PrintErr("need date,env ")
        exit(1)
    k_date = sys.argv[1]
    k_table = sys.argv[2] + "_cost_table"

    Conf.LoadConfig("./conf/config")

    GetInfo()

    WriteInfo()

    WriteHtml()
示例#4
0
    def __init__(self, fn, userInfo, mode='publish'):
        self.fn = fn
        self.userInfo = userInfo
        self.mode = mode
        self.warnIncomplete = 1
        tags = ''

        self.config = LoadConfig.LoadConfig()

        # open ogg file
        self.af = AudioFile(fn)
        self.metadata = self.af.read_comments()

        if self.mode is 'publish':
            newFilePath = self.fn
            logger.debug5("ImportOGG() self.fn: " + self.fn)
            logger.debug5("ImportOGG() newFilePath: " + newFilePath)

            if newFilePath:
                if self.import2db(newFilePath):
                    self.setImported()
        elif self.mode is 'edit':
            if self.import2db(self.fn):
                logger.debug1("Updated database from file: %s" % self.fn)
def printMenuButton(tk, text, mes, count, column, LogAddress, LogFile,
                    InstallAddress):
    FLAG = ServiceOpt.getServiceState(mes)

    # 判断地址
    SetupAddress = InstallAddress
    if mes == 'Face_Nginx':
        SetupAddress = LoadConfig.loadConfig("file_address", "NginxWebAddress")
    elif mes == 'Face_Mosquitto':
        SetupAddress = LoadConfig.loadConfig("file_address",
                                             "MosquittoAddress")

    btn = Menubutton(tk,
                     text=text,
                     anchor='w',
                     height=1,
                     relief=FLAT,
                     activeforeground="blue")
    btn.grid(row=count, column=column, sticky=W)

    fileMenu = Menu(btn, tearoff=False)

    # 启动服务
    fileMenu.add_command(label=START, command=lambda: btnStart(mes))

    def btnStart(mes):
        ServiceOpt.ServiceStart(mes)
        fileMenu.entryconfig(START, state=DISABLED)
        printLabel(tk, STATE_STARTING, count, 4, 1)

    # 停止服务
    fileMenu.add_command(label=STOP, command=lambda: btnStop(mes))

    def btnStop(mes):
        ServiceOpt.ServiceStop(mes)
        fileMenu.entryconfig(STOP, state=DISABLED)
        printLabel(tk, STATE_STOPPING, count, 4, 1)

    # 重启服务
    fileMenu.add_command(label=RE_START, command=lambda: btnReStart(mes))

    def btnReStart(mes):
        ServiceOpt.ServiceReStart(mes)
        fileMenu.entryconfig(RE_START, state=DISABLED)
        printLabel(tk, STATE_RE_STARTING, count, 4, 1)

    fileMenu.add_separator()

    # 打开服务日志
    fileMenu.add_command(label=LOG_FILE,
                         command=lambda: btnLogFile(LogAddress, LogFile))

    def btnLogFile(LogAddress, LogFile):
        ServiceOpt.openNoteByName(LogAddress, LogFile)
        fileMenu.entryconfig(LOG_FILE, state=DISABLED)

    fileMenu.add_separator()

    # 打开服务自启
    fileMenu.add_command(
        label=SET_START_AUTO,
        command=lambda: btnSetState(mes, SET_START_AUTO, "auto"))
    # 关闭服务自启
    fileMenu.add_command(
        label=SET_START_DEMAND,
        command=lambda: btnSetState(mes, SET_START_DEMAND, "demand"))
    # 禁用服务
    fileMenu.add_command(
        label=SET_START_DISABLED,
        command=lambda: btnSetState(mes, SET_START_DISABLED, "disabled"))

    def btnSetState(mes, label, STATE):
        ServiceOpt.ServiceSetStartAuto(mes, STATE)
        fileMenu.entryconfig(label, state=DISABLED)

    fileMenu.add_separator()

    # 安装服务
    fileMenu.add_command(label=INSTALL,
                         command=lambda: btnSetup(SetupAddress, mes))

    def btnSetup(SetupAddress, mes):
        ServiceOpt.openSetup(SetupAddress, mes)
        fileMenu.entryconfig(INSTALL, state=DISABLED)
        printLabel(tk, STATE_INSTALLING, count, 4, 1)

    # 卸载服务
    fileMenu.add_command(label=UNINSTALL, command=lambda: btnDelete(mes))

    def btnDelete(mes):
        ServiceOpt.ServiceDelete(mes)
        fileMenu.entryconfig(UNINSTALL, state=DISABLED)
        printLabel(tk, STATE_UNINSTALLING, count, 4, 1)

    if LogFile == '':
        fileMenu.entryconfig(LOG_FILE, state=DISABLED)

    if FLAG == -1:
        for index in [
                START, STOP, RE_START, SET_START_AUTO, SET_START_DEMAND,
                SET_START_DISABLED, UNINSTALL
        ]:
            fileMenu.entryconfig(index, state=DISABLED)
    elif FLAG == 0:
        fileMenu.entryconfig(STOP, state=DISABLED)
        fileMenu.entryconfig(INSTALL, state=DISABLED)
    elif FLAG == 1:
        fileMenu.entryconfig(START, state=DISABLED)
        fileMenu.entryconfig(INSTALL, state=DISABLED)

    btn.config(menu=fileMenu)
示例#6
0
    def __init__(self, userInfo):

        self.config = LoadConfig.LoadConfig()
        self.userInfo = userInfo
示例#7
0
############################
# Downloaded from: http://www.cli-apps.org/content/show.php/CLI+Music+Player?content=68462
###########################

######
#TODO#
#Implement pause#
#######################

import pygame, time, sys, os

sys.path.append("..")
import Common
import LoadConfig

config = LoadConfig.LoadConfig()
basedir = config.bshome
sys.path.append(config.bshome)
Common.Init(config.bshome)
import Database

Lp = 1
while Lp == 1:
    #MusicDir=raw_input('Please type a path to a music folder:')
    #os.chdir(MusicDir)
    Playlist = Database.GetPlaylist(11)
    print 'Playlist: '
    for file in Playlist:
        print file
    raw_input('Hit ENTER to continue.')
    try:
示例#8
0
    def __init__(self, fn=None):
        self.config = LoadConfig.LoadConfig()
	self.tagReader = 'mutagen' # can be mutagen or ID3

        if fn is not None:
            self.SetFile(fn)
示例#9
0
import LoadConfig
import BryxConnector
import HueController
import DatabaseConnector
import time

config = LoadConfig.Config()
config.loadConfig()
database = DatabaseConnector.Database(config)
hue = HueController.HueBridge(config.bridgeaddress)


def addCall(call):
    hue.turnOnLights()
    database.mycol.insert_one(call)


def updateCall(call):
    database.mycol.update_one({"id": call["id"]}, {"$set": call})


def searchCalls(calls):
    for call in calls:
        findCallQuery = {"id": call["id"]}
        mydoc = database.mycol.find_one(findCallQuery)
        if mydoc is None:
            addCall(call)
            print("Found new call")
        else:
            updateCall(call)
            print("Updated Call")
示例#10
0
def main(argv):
    c = lc.LoadConfig()
    L = get_qiita_daily(c.qiita_url)
    ss.send_slack(L, c)
示例#11
0

if __name__ == '__main__':
    create_Base_File()

    sdkConfig = getConfig()

    uuidMd5 = shortMD5(
        str(uuid.uuid3(uuid.NAMESPACE_DNS, 'python')).replace("-", ""))
    if not sdkConfig:
        exit(0)
    if not sdkConfig.get("key_file_" + uuidMd5):
        print("填写ssh 公钥 路径")
    ''' 填写默认信息  '''
    # 就是类是 俄服 内部测试服务器  ! 去掉
    testServerConfig = Update_joyfun.serverConfig()
    liveServerConfir = Update_joyfun.serverConfig()
    liveServerConfir.host = sdkConfig.get("host")  # '185.236.180.146'
    liveServerConfir.key_file = sdkConfig.get(
        "key_file_" + uuidMd5)  # '/Users/admin/.ssh/id_rsa'
    liveServerConfir.port = int(sdkConfig.get("port"))  #  2202
    liveServerConfir.username = sdkConfig.get("username")  # 'pikachuadmin'
    liveServerConfir.staticFile = sdkConfig.get(
        "staticFile")  #'/easygame/pikachu/gameweb/static/'
    liveServerConfir.gameHtmlFile = sdkConfig.get(
        "gameHtmlFile")  #"/easygame/pikachu/gameweb/game.html"
    ''' 同意时间字符串   '''
    dataStr = getDataStr()
    print("清理文件目录 serverFile  doUpdateFile  开始 ( 保证 每次都是最新的  )")
    del_file(os.path.dirname(__file__) + "/serverFile/")
    del_file(os.path.dirname(__file__) + "/doUpdateFile/")
示例#12
0
    for zoneInfo in gameZoneList:
        if zoneInfo['GameZoneID'] == zoneID:
            print zoneInfo
            return zoneInfo['ServerIP']


def GetGameZoneIDByIP(zoneIP):
    for zoneInfo in gameZoneList:
        if zoneInfo['ServerIP'] == zoneIP:
            return zoneInfo['GameZoneID']


def GetGameConfigByID(zoneID):
    for zoneInfo in gameZoneList:
        if zoneInfo['GameZoneID'] == zoneID:
            return zoneInfo


if __name__ == "__main__":

    if len(sys.argv) < 3:
        print "error need 3 args"
    os.chdir(sys.argv[1])
    gameConfig = LoadConfig.initConfig()
    gameZoneList = {}
    gameZoneList = gameConfig["GameZoneList"]
    template = changeTemplate.ConfigTemplate()
    template.Init()
    gameConfig = GetGameConfigByID(int(sys.argv[2]))
    template.ChangeFile(gameConfig)