Пример #1
0
def run():
    observer = None
    try:
        # 加载配置文件
        config = toml.load('config.toml')
        monitor_dir = config.get(
            'monitor_folder',
            os.path.join(os.path.expanduser("~"), 'Desktop', 'pdf'))
        global upload_url, device_no
        upload_url = config.get('upload_url',
                                "http://10.220.29.28:5000/api/v1/upload_pdf")
        device_no = config.get('device_no')
        # 开始监控文件夹
        observer = Observer()
        event_handler = FileEventHandler()
        observer.schedule(event_handler, monitor_dir, True)
        observer.start()
        # 提示运行成功
        logger.info("running.....")
        MessageBox(0, 'The successful running', "info", MB_OK)
    except FileNotFoundError:
        logger.error("please check config file")
        MessageBox(0, 'The Directory not found, please check config file',
                   "error", MB_OK)
        raise

    try:
        while True:
            time.sleep(1)
    except Exception:
        logger.error(traceback.format_exc())
        observer.stop()
    observer.join()
Пример #2
0
 def loginCheck(self):
     name = self.username.get()
     secret = self.password.get()
     if name=='wangliang' and secret=='123456':
         self.destroy()
         # MainPage()
     else:
         MessageBox.showinfo(title='错误', message='账号或密码错误!')
Пример #3
0
def mbox(title, text, style=''):
    from win32api import MessageBox
    if style == 'error':
        MessageBox(0, text, title, 16)  #win32con.MB_ICONERROR=16
    elif style == 'info':
        MessageBox(0, text, title, 64)  #win32con.MB_ICONASTERISK=64
    elif style == 'warn':
        MessageBox(0, text, title, 48)  #win32con.MB_ICONWARNING=48
    else:
        MessageBox(0, text, title, 0)  #win32con.MB_OK=0
Пример #4
0
def file_conflict(time,size):
    from win32api import MessageBox
    import win32con

    def compare(a,b):
        if a == b:return 0
        elif a > b:return 1
        else:return -1

    status = (compare(*time),compare(*size))
    if 1 in status:
        time_description = {1:'较新',-1:'较旧'}
        size_description = {1:'较大',-1:'较小'}
        description = time_description.get(status[0],'')+\
                      size_description.get(status[1],'')
        result = MessageBox(win32con.NULL,ASK_FILE.format(description),\
                            '文件冲突 (File Conflict)',\
                            win32con.MB_YESNO|win32con.MB_ICONQUESTION|\
                            win32con.MB_TOPMOST)
        # Yes:6, No:7
        return 7-result
    elif status == (0,0):
        return 0
    else:
        return 1
Пример #5
0
 def modify_value(self, index, newvalue):
     try:
         self.node
     except:
         MessageBox("error occurs when modifying the value of node %d",index)
     return
     pass
    def find_coord(self, n_frame: int):
        position = n_frame + self.fps / 2
        self.video.set(1, position)
        _, self.frame = self.video.read()
        self.areas, self.rect, self.frame = self.text_detection(self.frame)
        MessageBox(
            0, 'Selecione uma área ou arraste o cursor para criar uma nova.'
            '\n c - continuar \n r - redesenhar \n n - ir para o próximo frame',
            'Identifique a área da legenda')
        clone = self.frame.copy()
        cv2.namedWindow("image", cv2.WND_PROP_FULLSCREEN)
        cv2.setWindowProperty("image", cv2.WND_PROP_FULLSCREEN,
                              cv2.WINDOW_FULLSCREEN)
        cv2.setMouseCallback(
            "image",
            lambda *args, **kwargs: self.click_and_crop(*args, **kwargs))
        while True:
            # display the image and wait for a keypress
            cv2.imshow("image", self.frame)
            key = cv2.waitKey(1) & 0xFF
            if key == ord("r"):
                self.frame = clone.copy()
            if key == ord("n"):
                position += 1
                self.video.set(1, position)
                _, self.frame = self.video.read()
                clone = self.frame.copy()
            elif key == ord("c"):
                break
            elif key == 27:
                self.legend_location = []
                break

        # if there are two reference points, then crop the region of interest
        # from teh image and display it
        if self.legend_location and (self.legend_location[0][1] >
                                     self.legend_location[1][1]):
            self.legend_location[1][1], self.legend_location[0][1] = (
                self.legend_location[0][1], self.legend_location[1][1])

        if self.legend_location and (self.legend_location[0][0] >
                                     self.legend_location[1][0]):
            self.legend_location[1][0], self.legend_location[0][0] = (
                self.legend_location[0][0], self.legend_location[1][0])

        if self.legend_location and (
                self.legend_location[0][1] == self.legend_location[1][1]
                or self.legend_location[0][0] == self.legend_location[1][0]):
            print(
                "Não é possível gerar um recorte a partir da área selecionada")

        self.legend_location = [
            refPt[0][1], refPt[1][1], refPt[0][0], refPt[1][0]
        ]

        cv2.destroyAllWindows()
        self.location_slice = slice(*self.legend_location[2:]), slice(
            *self.legend_location[:2])
        return self.legend_location
Пример #7
0
def checkbox_on_action(checked, control):
    """Called when the checkBox is checked or unchecked."""
    msg = "Checkbox is now "
    if checked:
        msg += "checked"
    else:
        msg += "unchecked"
    MessageBox(None, msg, "", MB_TASKMODAL)
Пример #8
0
def main():
    try:
        event_provider = get_event_provider("outlook_local", config_storage)
        slack_wrapper = SlackStatusUpdater(token)

        status_message = get_updated_status_message(event_provider, config_storage)
        emoji = slack_wrapper.get_status_emoji(status_message)

        logging.info("Detected status: {}".format(status_message))
        logging.info("Detected emoji: {}".format(emoji))

        update(slack_wrapper, status_message, emoji, force_write=force)
    except UserException as e:
        MessageBox(0, "{}. \r\n\r\n{}".format(e.message, e.details), "Slack Status Updater Error")
        logging.exception("User exception encountered")
    except Exception:
        logging.exception("A fatal error occurred")
Пример #9
0
from os import listdir, curdir
from re import sub
from win32api import MessageBox

for file in listdir(curdir):
    if "GT-MP-" in file and ".log" in file:
        with open(file) as log:
            with open("CHATLOG-" + file.strip(".log") + ".txt",
                      'w+') as chatlog:
                chatlog.write(
                    "GT-MP Chatlog Extractor Tool v1.0 (via github user charlw & mt-gaming user Trippy)\n"
                )
                for line in log:
                    if "[ClassicChat]" in line[:37]:
                        line = line[37:]
                        if "~" in line:
                            if "~#" in line[:2]:
                                line = line[11:]
                            else:
                                line = sub('~[A-Za-z]~', '', line)
                        chatlog.write(line)

if not any("CHATLOG" in filename for filename in listdir(curdir)):
    MessageBox(
        0,
        "Ensure GT-MP Chatlog Extractor.exe is placed in folder containing logs you want to convert to chatlogs!",
        "GT-MP Chatlog Extractor Tool")
Пример #10
0
def alert(title: str, message: str):
    MessageBox(0, message, title, 0x00001000)
Пример #11
0
def month_selected(item_idx, item_id, control):
    """Called when something is selected from the Months gallery."""
    MessageBox(None, "%s selected" % item_id, "Months", MB_TASKMODAL)
Пример #12
0
from win32api import MessageBox
import win32con
from os import _exit


warn = lambda m: MessageBox(0, str(m), "Warning",\
                            win32con.MB_ICONEXCLAMATION|win32con.MB_TOPMOST)


class Warner:
    def __init__(self, file, message):
        self.message = message
        self.file = file

    def write(self, message):
        self.message += message
        return

    def __del__(self):
        from time import ctime

        warn(self.message)
        with open(self.file, 'a') as f:
            f.write('\n' + '-' * 20 + ctime() + '-' * 20 + '\n')
            f.write(self.message)
        print(self.message)


def log_and_exit(file='log.txt', message='', to_exit=True):
    from traceback import print_exc
Пример #13
0
def alert(msg, barcode):
    MessageBox(0, msg, barcode, 0x00001030)
Пример #14
0
def show_time_zones(control):
    """Called when the Regional Settings button in the gallery is clicked."""
    # This could be a more complex form using another windowing toolkit such as Qt or Wx.
    MessageBox(None, "This is where you would put your timezone options",
               "Timezones", MB_TASKMODAL)
Пример #15
0
  0x602D10EB, 0x426C, 0x4D6F, 0xA4, 0xDF, 0xC0, 0x55, 0x72, 0xEB, 0x78, 0x0B);

DISPID rgDispId ;
OLECHAR * rgszNames [ ] = { OLESTR ( "new" ) };
DISPPARAMS DispParams;
VARIANT VarResult;
EXCEPINFO excepinfo;
UINT uArgErr;
VARIANTARG * pvarg = NULL;
_bstr_t stemmedWord;
HRESULT hr;
IDispatch * stemmerFactory;
IDispatch * stemmer;

if ( FAILED ( hr = CoInitialize ( NULL ) ) ) {
    MessageBox ( 0, "CoInitialize failure", "Fault", MB_OK );
    break;
}

if ( FAILED ( hr = CoCreateInstance (
    CLSID_StemmerFactory,
    NULL,
    CLSCTX_INPROC_SERVER,
    IID_IDispatch,
    ( LPVOID * ) & stemmerFactory ) ) ) {
    MessageBox ( 0, "CoCreateInstance failure", "Fault", MB_OK );
    break;
}

if ( FAILED ( hr = stemmerFactory -> GetIDsOfNames (
    IID_NULL,
Пример #16
0
def combo_box_on_change(item, control):
    """Called when the comboBox selection is changed."""
    MessageBox(None, "%s is now %s" % (control.Id, item), "", MB_TASKMODAL)
Пример #17
0
def ShowMessage(msg, title='Info'):
    "Function to show messages to windows users. This is only used by the demo."
    from win32api import MessageBox
    MessageBox(0, msg, title)
Пример #18
0
def msg(text, title):
    MessageBox(0, text, title)
Пример #19
0
        MessageBox(0, 'The successful running', "info", MB_OK)
    except FileNotFoundError:
        logger.error("please check config file")
        MessageBox(0, 'The Directory not found, please check config file',
                   "error", MB_OK)
        raise

    try:
        while True:
            time.sleep(1)
    except Exception:
        logger.error(traceback.format_exc())
        observer.stop()
    observer.join()


if __name__ == "__main__":

    # 文件互斥,保证运行一次
    mutex = CreateMutex(None, True, 'file_change_mabo_tech')
    last_error = GetLastError()

    if last_error > 0:
        # 如果已经运行给出提示
        MessageBox(0, 'Please do not repeat!', "warning", MB_OK)
    else:
        try:
            run()
        except Exception:
            logger.error(traceback.format_exc())