Exemple #1
0
    def start(self):
        """
        Starts CloudBot.
        This method first connects all of the IRC connections, then receives input from the IRC engine and processes it
        """
        # start connections
        for conn in self.connections:
            conn.connect()

        self.logger.info("Starting main thread.")
        while self.running:
            # This method will block until a new message is received.
            message = self.queued_messages.get()

            if not self.running:
                # When the bot is stopped, StopIteration is put into the queue to make sure that
                # self.queued_messages.get() doesn't block this thread forever.
                # But we don't actually want to process that message, so if we're stopped, just exit.
                return

            if message.get("reconnect", False):
                # The IRC engine will put {"reconnect": True, "conn": BotConnection} into the message queue when the
                # connection times out, and it needs to be restarted. We'll do that.
                connection = message["conn"]
                self.logger.info("[{}] Reconnecting to IRC server".format(
                    connection.readable_name))
                connection.connection.reconnect()
                # We've dealt with this message, no need to send it to main
                continue

            main.main(self, message)
Exemple #2
0
    def start(self):
        """
        Starts CloudBot.
        This method first connects all of the IRC connections, then receives input from the IRC engine and processes it
        """
        # start connections
        for conn in self.connections:
            conn.connect()

        self.logger.info("Starting main thread.")
        while self.running:
            # This method will block until a new message is received.
            message = self.queued_messages.get()

            if not self.running:
                # When the bot is stopped, StopIteration is put into the queue to make sure that
                # self.queued_messages.get() doesn't block this thread forever.
                # But we don't actually want to process that message, so if we're stopped, just exit.
                return

            if message.get("reconnect", False):
                # The IRC engine will put {"reconnect": True, "conn": BotConnection} into the message queue when the
                # connection times out, and it needs to be restarted. We'll do that.
                connection = message["conn"]
                self.logger.info("[{}] Reconnecting to IRC server".format(connection.readable_name))
                connection.connection.reconnect()
                # We've dealt with this message, no need to send it to main
                continue

            main.main(self, message)
Exemple #3
0
def print_host():
    h_list = []
    host_list = create_host.Host_info.get_host()
    for host in host_list.keys():
        h_list.append(host)
        print(host)
    if not h_list:
        exit('没有主机可以操作,请先添加主机')
    else:
        main.main()
Exemple #4
0
    def run(self):
        """recieves input from the IRC engine and processes it"""
        self.logger.info("Starting main thread.")
        while self.running:
            for conn in self.connections.itervalues():
                try:
                    incoming = conn.parsed_queue.get_nowait()
                    if incoming == StopIteration:
                        # IRC engine has signalled timeout, so reconnect (ugly)
                        conn.connection.reconnect()
                    main.main(self, conn, incoming)
                except Queue.Empty:
                    pass

            # if no messages are in the incoming queue, sleep
            while all(connection.parsed_queue.empty()
                      for connection in self.connections.itervalues()):
                time.sleep(.1)
Exemple #5
0
# ----------------------------------------------------------------------------------------------------------------------
from core.main import main


if __name__ == '__main__':
    arguments_parser = argparse.ArgumentParser(description='Scrapping of the https://energiya-prirody.prom.ua/')

    arguments_parser.add_argument(
        '--link',
        required=False,
        help='URL on products group; by default website homepage'
    )
    arguments_parser.add_argument(
        '--directory',
        required=False,
        help='Path to dump reports; by default created in the project dir'
    )
    arguments_parser.add_argument(
        '--workers',
        required=False,
        help='Workers to request the website; by default is one'
    )

    arguments = arguments_parser.parse_args()

    main(
        link=arguments.link,
        directory=arguments.directory,
        workers=arguments.workers
    )
Exemple #6
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from core.main import main

main()
Exemple #7
0
import os
import sys
sys.path.append(os.path.dirname(os.getcwd()))  #添加项目根目录到系统环境变量

from core import main
from core import checkfiles  # 检测配置项中的文本文件是否存在,不存在则创建

if __name__ == '__main__':
    main.main()  # 程序核心入口
Exemple #8
0
import os
import sys
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(base_dir)
from core import main

if __name__ == '__main__':
    main.main()
Exemple #9
0
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Author :wangliujun
import os
import sys

base_dir = os.path.dirname(os.path.dirname(__file__))  # 获取当前文件所在目录
sys.path.append(base_dir)

from core import main as m
from core import manager as ma
from core import student as stu
from core.course import *
from core.student import *

# print(sys.modules[stu])

if __name__ == '__main__':
    m.main()
def test_main():
    assert main() == 0
Exemple #11
0
#执行文件
#!/usr/bin/env  python3
import sys, os, requests
Base_dir = os.path.dirname(os.path.dirname(
    os.path.abspath(__file__)))  #将server_cmdb设为基目录

sys.path.insert(0, Base_dir)

from core.main import main  #导入main模块

if __name__ == "__main__":
    info = main()
    requests.post(url='http://47.98.34.58:11223/cmdb/asset/', json=info)
Exemple #12
0
"""
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
if __name__ == "__main__":
    import os
    import sys
    import xbmcaddon

    libs = os.path.join(xbmcaddon.Addon().getAddonInfo("path"), "lib")
    sys.path.append(libs)

    from core import main

    main.main()
Exemple #13
0
'''Usage:
    gendiff.py [options] <firstConfig> <secondConfig>

   Compares two configuration files and shows a difference.

   Options:
    -h --​help  output usage information
    -v --version  output the version number
    -f --format [​type​]  Output format
'''
import sys
from docopt import docopt
from core import __version__
from core.main import main

if __name__ == '__main__':
    namespace = docopt(__doc__, version=__version__)
    if namespace.get('<firstConfig>') is not None:
        res = main(first=namespace.get('<firstConfig>'),
                   second=namespace.get('<secondConfig>'),
                   format_=namespace.get('--format'))
        sys.stdout.write(res)
Exemple #14
0
#!/usr/bin/env python3
import sys,os,requests
path=os.path.abspath(__file__)  #获取当前文件的绝对路径
path=os.path.dirname(path)   #只获取这个路径的目录
path=os.path.dirname(path)   #在一次执行这个,把bin去掉

Base_dir=path             #将这个路径作为基础路径
sys.path.insert(0,Base_dir)  #插入到sys.path中,导入模块时以这个路径为基础路径

from core.main import main  #导入core下的main模块的main对象


if __name__ == "__main__":
    info=main()    #实例化对象并且接受返回值
    print(info)
#    print(info)    #输出返回值
    requests.post(url="http://127.0.0.1:8000/cmdb/asset/",json=info)
Exemple #15
0
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Xiaobai Lei
'''整个程序启动入口'''
import sys
import os
top_path = os.path.dirname(os.path.dirname(__file__))  # 最顶层目录路径
sys.path.append(top_path)  # 加入到系统路径,方便模块导入
from core import main

if __name__ == '__main__':
    main.main()  #执行程序主函数
Exemple #16
0
"""
This is the main entry point of the game.
"""
import sys
import pygame as pg     # sets pg as an alias for pygame

from core.main import main
from core.main import util
if __name__ == '__main__':
    main()      # Calls the main game loop  - see main.py
    pg.quit()   # Uninitializes all pygame modules
    sys.exit()  # Exits the app

 
Exemple #17
0
# coding: utf-8
from core.main import main, ftp_server
from core.concurrency import queue_pool, muti_server
# 从各个模块中导入函数,运行程序
if __name__ == '__main__':
    print("Ftp 服务正在运行......")
    main(ftp_server, muti_server, queue_pool)
Exemple #18
0
from core.main import main


if __name__ == '__main__':
    main()
Exemple #19
0
from core.main import main

info= main()   #接受main函数的返回值
print(info)    #输出