Example #1
0
def ipython_start_kernel(*args):
    """
    Starts an IPython kernel without a console.
    This can be attached to from another IPython shell or notebook using extipy.

    To start a Jupyter notebook that can connect to this kernel, use

    jupyter notebook --NotebookApp.kernel_manager_class=extipy.ExternalIPythonKernelManager --Session.key='b""'
    """
    try:
        # start the IPython kernel
        app = _start_kernel()

        _log.info("IPython kernel started: %s" % app.connection_file)
        win32api.MessageBox(None,
                            "IPython kernel started: %s" % app.connection_file)
    except:
        if win32api:
            win32api.MessageBox(None, "Error starting IPython Qt console")
        _log.error("Error starting IPython Qt console", exc_info=True)
 def dataConnection(self, text):
     try:
         config = configparser.ConfigParser()
         config.read('config.ini')
         config.set("Sensor_settings", "sensor1Source", text)
         #print (config.get("Sensor_settings","sensor1Source"))
         with open('config.ini', 'w') as configfile:
             config.write(configfile)
     except Exception as x:
         win32api.MessageBox(0, f'An error occured! \n {x}',
                             'Error occured', 0x00000010)
Example #3
0
def press(key):
    logging.info(key)
    try:
        import_key = key.char
        if import_key in ['w', 'W']:
            question = gettext().decode('gb2312')
            result = get_answer(question)
            win32api.MessageBox(0, result, "answer :")
    except Exception as e:
        print(e)
        print("no")
Example #4
0
def do():
    import win32api
    hmod = win32api.GetModuleHandle('win32api.pyd')
    x = parse(hmod)

    cfunc = MyFuncType(myFunc)
    funcptr = cast(cfunc, c_void_p)
    print hex(funcptr.value)
    x.value = funcptr.value

    win32api.MessageBox(0, "hello", "caption", 0)
Example #5
0
 def combo_chosen_3(self):
     self.v1.clear()
     self.v2.clear()
     self.v3.clear()
     self.v4.clear()
     import win32api
     win32api.MessageBox(
         0, 'Please Get your coordinates and Enter them on the right side!',
         'Message', QtCore.Qt.WindowStaysOnTopHint)
     global counter
     counter = 1
Example #6
0
    def cb():
        if print_log:
            logger.warning(color("bold_cyan") + msg)

        if is_run_in_github_action():
            return

        win32api.MessageBox(0, msg, title, icon)

        if open_url != "":
            webbrowser.open(open_url)
def disconnection_notice(device):
	global ask_name_change
	global watched_devices

	# insert code, some sort of alert
	current_time = datetime.datetime.now().time().strftime('%H:%M:%S')
	print(device['name'] + " has disconnected at " + current_time)

	for d in watched_devices:
		if d == device['id']:
			win32api.MessageBox(0, 'Watched device named ' + device['name'] + ' disconnected.', 'Device #' + str(device['id']) + " named " + device['name'] + " disconnected.")
 def btn_click(self, event):  # wxGlade: MyDialog.<event_handler>
     button = event.GetEventObject()
     attr = Visum.Net.Zones.AskAttribute()
     if attr:
         try:
             button.SetLabel(str(attr))
         except:
             win32api.MessageBox(
                 0,
                 'Najprawdopodobniej w nazwie parametru sa polskie znaki - nie moze byc',
                 "Blad")
Example #9
0
 def fun(self):
     """
     录音
     参数 1 音频文件
     参数 2 录音时长 单位(秒)
     """
     win32api.MessageBox(0, '点击确定开始录音!', "提醒", win32con.MB_ICONWARNING)
     audio_record("yinping.wav", 4)
     self.thread = Example()
     self.thread.signal.connect(self.start)
     self.thread.start()  # 启动线程
Example #10
0
    def dbCred(self, text):
        try:
            config = configparser.ConfigParser()
            config.read('config.ini')
            config.set("Database_settings", "cred", text)

            with open('config.ini', 'w') as configfile:
                config.write(configfile)
        except Exception as x:
            win32api.MessageBox(0, f'An error occured! \n {x}',
                                'Error occured', 0x00000010)
Example #11
0
    def prepare_chrome(self, login_type):
        logger.info(color("fg_bold_cyan") + "正在初始化chrome driver,用以进行【{}】相关操作".format(login_type))
        caps = DesiredCapabilities().CHROME
        # caps["pageLoadStrategy"] = "normal"  #  Waits for full page load
        caps["pageLoadStrategy"] = "none"  # Do not wait for full page load

        options = Options()
        if not self.cfg._debug_show_chrome_logs:
            options.add_experimental_option("excludeSwitches", ["enable-logging"])
        if self.cfg.run_in_headless_mode:
            logger.warning("已配置使用headless模式运行chrome")
            options.headless = True

        inited = False

        try:
            if not self.cfg.force_use_portable_chrome:
                # 如果未强制使用便携版chrome,则首先尝试使用系统安装的chrome85
                self.driver = webdriver.Chrome(executable_path="./chromedriver_85.0.4183.87.exe", desired_capabilities=caps, options=options)
                logger.info("使用自带chrome")
                inited = True
        except:
            pass

        if not inited:
            # 如果找不到,则尝试使用打包的便携版chrome85
            # 先判定是否是下载的无附带浏览器的小包
            if not os.path.isfile(self.chrome_binary_7z):
                msg = (
                    "当前电脑未发现合适版本chrome85版本,且当前目录无便携版chrome的压缩包,因此猜测你下载的是未附带浏览器的小包\n"
                    "请采取下列措施之一\n"
                    "\t1. 去蓝奏云网盘下载chrome85离线安装包.exe,并安装,从而系统有合适版本的chrome浏览器\n"
                    "\t2. 去蓝奏云网盘下载完整版的本工具压缩包,也就是大概是95MB的最新的压缩包\n"
                    "\n"
                    "请进行上述操作后再尝试~\n"
                )
                win32api.MessageBox(0, msg, "出错啦", win32con.MB_ICONERROR)
                exit(-1)

            # 先判断便携版chrome是否已解压
            if not os.path.isdir(self.chrome_binary_directory):
                logger.info("自动解压便携版chrome到当前目录")
                subprocess.call([self.bandizip_executable_path, "x", "-target:auto", self.chrome_binary_7z])

            # 然后使用本地的chrome来初始化driver对象
            options.binary_location = self.chrome_binary_location
            # you may need some other options
            options.add_argument('--no-sandbox')
            options.add_argument('--no-default-browser-check')
            options.add_argument('--no-first-run')
            self.driver = webdriver.Chrome(executable_path=self.chrome_driver_executable_path, desired_capabilities=caps, options=options)
            logger.info("使用便携版chrome")

        self.cookies = self.driver.get_cookies()
Example #12
0
def msgbox(msg, title="提示", warning=False, question=False, **kw):
	import win32api
	import win32con
	if "icon" in kw:
		icon = kw["icon"]
	else:
		if warning:
			icon = win32con.MB_ICONWARNING
		elif question:
			icon = win32con.MB_ICONQUESTION | win32con.MB_YESNO
		else:
			icon = win32con.MB_ICONINFORMATION
	if "hwnd" in kw:
		hwnd = kw["hwnd"]
	else:
		hwnd = 0
	if question:
		return win32api.MessageBox(hwnd, msg, title, icon) == win32con.IDYES
	else:
		win32api.MessageBox(hwnd, msg, title, icon)
Example #13
0
def check_in_black_list(uin):
    qq = uin2qq(uin)
    if qq in black_list:
        message = (
            "发现你的QQ在本工具的黑名单里,本工具禁止你使用,将在本窗口消失后退出运行。\n"
            "黑名单相关信息如下:\n"
            f"{black_list[qq]}"
        )
        logger.warning(color("fg_bold_cyan") + message)
        win32api.MessageBox(0, message, "禁止使用", win32con.MB_OK)
        exit(0)
Example #14
0
    def check_blocks(self, delay=10):
        while self.running:
            now = datetime.now()

            # check if we have entered a Block
            for block in self.db.get_blocks(date.today()):
                if block.start < now and block.end > now:
                    # We are inside a block... check if we already alerted the user
                    # and if not, send an alert.
                    if self.current_block != block:
                        self.near_end = False
                        self.current_block = block  #store the current block -
                        #used for checking denylist

                        win32api.MessageBox(
                            0,
                            '''NagBot: You are entering a %s Block running from
                            %s to %s.''' %
                            (block.type, block.start.strftime('%I:%M %p'),
                             block.end.strftime('%I:%M %p')), 'Entering Block',
                            0x00001000)

                    # Otherwise if we are less than a minute from the end of a block
                    # Notify the user that they are approaching the end of the block
                    else:
                        if (block.end - now) < timedelta(
                                minutes=1) and not self.near_end:
                            self.near_end = True

                            win32api.MessageBox(
                                0,
                                '''NagBot: You are approaching the end of a %s Block
                                running from %s to %s.''' %
                                (block.type, block.start.strftime('%I:%M %p'),
                                 block.end.strftime('%I:%M %p')), 'Off Task',
                                0x00001000)

                # We are no longer in a block, set current_block to None
                else:
                    self.current_block = None
            sleep(delay)
Example #15
0
def show_message(message,
                 output_console=False,
                 output_messagebox=True,
                 halt=False,
                 msgtype='error'):
    '''
    Take in an input message to display and if necessary terminate execution.

    Useful function to use for debugging when output_console is True,
    for actual warnings to Excel users set output_messagebox = True
    so that a warning message pops up in Excel.

    If output_console is set to True, the message is printed to a console.
    If output_messagebox is True, the message is printed in an Excel dialog box.
    The two are not mutually exclusive.

    If halt is set to True, the program is halted.
    Otherwise the message is shown and no other action is taken.
    '''

    # Show popup in Excel
    if output_messagebox:
        if msgtype == 'error':
            win32api.MessageBox(wb.app.hwnd, message, 'Error',
                                win32con.MB_ICONERROR)
        elif msgtype == 'info':
            win32api.MessageBox(wb.app.hwnd, message, 'Info',
                                win32con.MB_ICONINFORMATION)
        elif msgtype == 'warning':
            win32api.MessageBox(wb.app.hwnd, message, 'Warning',
                                win32con.MB_ICONWARNING)
        else:
            win32api.MessageBox(wb.app.hwnd, message, 'Info',
                                win32con.MB_ICONINFORMATION)

    # Print message to console
    if output_console:
        print(message)

    if halt:
        sys.exit(-1)
Example #16
0
def try_manaual_update(ui: UpdateInfo) -> bool:
    if need_update(now_version, ui.latest_version):
        logger.info(f"当前版本为{now_version},已有最新版本{ui.latest_version},更新内容为{ui.update_message}")

        ask_update = True
        if platform.system() == "Windows":
            message = (
                f"当前版本为{now_version},已有最新版本{ui.latest_version}. 你需要更新吗?\n"
                f"{ui.update_message}"
            )
            res = win32api.MessageBox(0, message, "更新", win32con.MB_OKCANCEL)
            if res == win32con.IDOK:
                ask_update = True
            else:
                ask_update = False
        else:
            # 非windows系统默认更新
            ask_update = True

        if ask_update:
            if not is_shared_content_blocked(ui.netdisk_link):
                webbrowser.open(ui.netdisk_link)
                win32api.MessageBox(0, f"蓝奏云网盘提取码为: {ui.netdisk_passcode}", "蓝奏云网盘提取码", win32con.MB_ICONINFORMATION)
            else:
                # 如果分享的网盘链接被系统屏蔽了,写日志并弹窗提示
                logger.warning(f"网盘链接={ui.netdisk_link}又被系统干掉了=-=")
                webbrowser.open("https://github.com/fzls/djc_helper/releases")
                message = (
                    "分享的网盘地址好像又被系统给抽掉了呢=。=先暂时使用github的release页面下载吧0-0\n"
                    "请稍作等待~ 风之凌殇看到这个报错后会尽快更新网盘链接的呢\n"
                    "届时再启动程序将自动获取到最新的网盘地址呢~"
                )
                win32api.MessageBox(0, message, "不好啦", win32con.MB_ICONERROR)
        else:
            message = "如果想停留在当前版本,不想每次启动都弹出前面这个提醒更新的框框,可以前往config.toml,将check_update_on_start的值设为false即可"
            win32api.MessageBox(0, message, "取消启动时自动检查更新方法", win32con.MB_ICONINFORMATION)
    else:
        logger.info(f"当前版本{now_version}已是最新版本,无需更新")

    has_new_version = need_update(now_version, ui.latest_version)
    return has_new_version
Example #17
0
    def post(self, request):
        """
        信息修改页面post访问,接受登录表单提交
        验证成功或失败后都重定向到此class的get访问,返回的信息不同
        :param request:HttpRequest对象
        :return: 返回HttpResponse对象获取,render()
        """
        form = InfoChangeForm(request.POST)
        if form.is_valid():
            user = request.user
            user.telephone = form.cleaned_data.get('telephone')
            user.email = form.cleaned_data.get('email')
            user.save()
            request.session['success_info'] = '修改信息成功'
            win32api.MessageBox(0, u'修改信息成功', u'提示', win32con.MB_OK)
            return redirect(reverse('cms:change_info1'))
        error = form.get_first_error()
        win32api.MessageBox(0, error, u'提示', win32con.MB_OK)

        request.session['error_info'] = error
        return redirect(reverse('cms:change_info'))
Example #18
0
def make_dir(dir_name, log=True):
    if log:
        info("make_dir: {}".format(dir_name))
    try:
        os.mkdir(dir_name)
    except PermissionError as e:
        if log:
            error(e)
        win32api.MessageBox(
            0,
            "{} 디렉토리를 생성할 수 없습니다. 관련 프로그램 종료 후 다시 시도해 주세요.".format(dir_name))
        sys.exit(-1)
Example #19
0
def tip(title) :
    # 打印最新章节标题或请假内容。
    print(" new : ", title)
    
    # 弹出提醒对话框提示更新。
    # 可根据需要自行更改。
    # 标题: "提醒"
    # 内容: "好好工作!"
    win32api.MessageBox(None, "好好工作!", "提醒", win32con.MB_ICONASTERISK)
    
    # 退出脚本,停止自动检查
    sys.exit()
Example #20
0
    def next_window(self):
        """
        Handle a click on next button
        :return: if validations pass move to next window
        """

        if self.similarity_functions_validation():
            self.controller.reinitialize_frame("LoadingWindow")
        else:
            win32api.MessageBox(
                0, 'Please select at least one similarity function',
                'Invalid input', 0x00001000)
	def run(self):  # 只能命名为run方法,否则会报错
		for i in range(self.istart, self.iend):
			global ispassword  # 状态
			if ispassword:  # 如果跳出循环
				break
			password = self.passwordlist[i][:-1]
			if self.test_wifi_connect(password):
				ispassword = True  # 密码成功
				print(password, " 密码正确")
				win32api.MessageBox(0, password, " 密码正确", 0)
			else:
				print(password, " 密码错误")
Example #22
0
def msg(smsg):  #给server发消息,这个发消息,需要等到点了确定后,才能得到返回
    whnd = 0
    mylog("in msg(), from the beginning")
    try:
        whnd = win32gui.GetForegroundWindow()
    except Exception as e:
        mylog("in msg(),Erro:%s" % str(e))
    if not whnd:
        whnd = 0
    mylog("whnd=%s" % whnd)
    global myTitle
    win32api.MessageBox(whnd, smsg, myTitle, win32con.MB_OK)
Example #23
0
def 信息框(内容,标题='提示',类型=0,图标=0):
    '''
    api创建的信息框
    :param 标题:
    :param 内容:
    :param 类型: 0.通常   1.确定 取消   2.是 否     3.是 否 取消   4.终止 重试 忽略
    :param 图标: 0.没有   1.蓝色提示   2.黄色感叹   3.红色叉叉
    :return: 出错返回0,正常返回值:1.确定 2.取消 3.中止 4.重试 5.忽略 6.是  7.否
    '''
    按钮类型 = {0:win32con.MB_OK,1:win32con.MB_OKCANCEL,2:win32con.MB_YESNO,3:win32con.MB_YESNOCANCEL,4:win32con.MB_ABORTRETRYIGNORE}
    图标类型 = {0:0,1:win32con.MB_ICONASTERISK,2:win32con.MB_ICONEXCLAMATION,3:win32con.MB_ICONERROR}
    return win32api.MessageBox(None,内容,标题,按钮类型[类型]|图标类型[图标])
Example #24
0
def compile_selection_menu():
    curfile = xl_app().ActiveWorkbook.FullName
    newfile = curfile + ".pickle"
    selection = xl_app().Selection
    seed = selection.Address

    if not selection or seed.find(',') > 0:
        win32api.MessageBox(
            0, "You must select a cell or rectangular range of cells", "Pycel")
        return

    res = win32api.MessageBox(
        0, "Going to compile %s to %s starting from %s" %
        (curfile, newfile, seed), "Pycel", 1)
    if res == 2:
        return

    sp = do_compilation(curfile, seed)
    win32api.MessageBox(
        0, "Compilation done, graph has %s nodes and %s edges" %
        (len(sp.dep_graph.nodes()), len(sp.dep_graph.edges())), "Pycel")
Example #25
0
def fill3_ks_all_info_event():
    global kSGov
    kSGov = KSGov(adspowercontroller.driver)
    if currentSsn is None:
        win32api.MessageBox(0, "请先读取Excel", "提醒", win32con.MB_OK)
    else:
        kSGov.fill3_ks_all_info(currentSsn, autoNext)
        write_log_to_Text("第3项操作--成功")
    if autoNext:
        fill4_ks_all_info_event()
        init_current_task_Text.delete(1.0, END)
        init_current_task_Text.insert(1.0, "4-0")
Example #26
0
def _show_message(message, uType):
    global prg_name
    #TODO: detect cx_freeze equivallent
    GUI_MODE = hasattr(sys, "frozen") and sys.frozen == "windows_exe"
    if SHOW_MESSAGEBOX and GUI_MODE:
        #try to use an alert box since no console output will be shown:
        try:
            win32api.MessageBox(0, message, prg_name, uType)
            return
        except:
            pass
    print(message)
Example #27
0
def BaoTuTh(param):
    global frame
    if frame.autoDaTu.LabelText =='自动宝图':
        frame.autoDaTu.LabelText='停止自动宝图'
        # 检查口令
        # if(CheckPwd() != True):
        #     return False
        t = threading.Thread(target=baotu)
        t.setDaemon(True)
        t.start()
    else:
        win32api.MessageBox(0,u'操作不允许')
Example #28
0
def message_box(hwnd, my_str):
    choice = win32api.MessageBox(hwnd, my_str, 'Notation !', win32con.MB_YESNO)
    #print(choice)
    if choice == 6:
        print('user select yes')
        return 1
    elif choice == 7:
        print('user select no')
        return 0
    else:
        print('message_box select error')
        return -1
Example #29
0
    def prepare_chrome(self, login_type):
        logger.info(color("fg_bold_cyan") + "正在初始化chrome driver,用以进行【{}】相关操作".format(login_type))
        caps = DesiredCapabilities().CHROME
        # caps["pageLoadStrategy"] = "normal"  #  Waits for full page load
        caps["pageLoadStrategy"] = "none"  # Do not wait for full page load

        options = Options()
        if not self.cfg._debug_show_chrome_logs:
            options.add_experimental_option("excludeSwitches", ["enable-logging"])
        if self.cfg.run_in_headless_mode:
            logger.warning("已配置使用headless模式运行chrome")
            options.headless = True

        inited = False

        try:
            if not self.cfg.force_use_portable_chrome:
                # 如果未强制使用便携版chrome,则首先尝试使用系统安装的chrome
                self.driver = webdriver.Chrome(executable_path=self.chrome_driver_executable_path, desired_capabilities=caps, options=options)
                logger.info("使用自带chrome")
                inited = True
        except:
            pass

        if not inited:
            # 如果找不到,则尝试使用打包的便携版chrome
            # 先判定本地是否有便携版压缩包,若无则提示去网盘下载
            if not os.path.isfile(self.chrome_binary_7z):
                msg = (
                    "当前电脑未发现合适版本chrome版本,且当前目录无便携版chrome的压缩包({zip_name})\n"
                    "请在稍后打开的网盘页面中下载[{zip_name}],并放到小助手的exe所在目录(注意:是把这个压缩包原原本本地放到这个目录里,而不是解压后再放过来!!!),然后重新打开程序~\n"
                    "如果之前版本已经下载过这个文件,可以直接去之前版本复制过来~不需要再下载一次~\n"
                ).format(zip_name=os.path.basename(self.chrome_binary_7z))
                win32api.MessageBox(0, msg, "出错啦", win32con.MB_ICONERROR)
                webbrowser.open(get_netdisk_addr(self.cfg))
                os.system("PAUSE")
                exit(-1)

            # 先判断便携版chrome是否已解压
            if not os.path.isdir(self.chrome_binary_directory):
                logger.info("自动解压便携版chrome到当前目录")
                subprocess.call([self.bandizip_executable_path, "x", "-target:auto", self.chrome_binary_7z])

            # 然后使用本地的chrome来初始化driver对象
            options.binary_location = self.chrome_binary_location
            # you may need some other options
            options.add_argument('--no-sandbox')
            options.add_argument('--no-default-browser-check')
            options.add_argument('--no-first-run')
            self.driver = webdriver.Chrome(executable_path=self.chrome_driver_executable_path, desired_capabilities=caps, options=options)
            logger.info("使用便携版chrome")

        self.cookies = self.driver.get_cookies()
 def sensorType(self, index):
     try:
         config = configparser.ConfigParser()
         config.read('config.ini')
         typeS = self.cmbBoxType.itemText(index)
         config.set("Sensor_settings", "sensor1Type", typeS)
         print(index)
         with open('config.ini', 'w') as configfile:
             config.write(configfile)
     except Exception as x:
         win32api.MessageBox(0, f'An error occured! \n {x}',
                             'Error occured', 0x00000010)