예제 #1
0
def search_keyword_doc(docid, doc_data, kw_list, keywordtype, formtype):
    if formtype == 'PDF':
        with open(common.cur_file_dir() + '\\temp\\' + str(docid) + '.pdf',
                  'wb') as f:
            f.write(doc_data)
        doc_text = get_pdf_text(
            docid,
            common.cur_file_dir() + '\\temp\\' + str(docid) + '.pdf')
        result = keyword_count(docid, kw_list, keywordtype, doc_text, formtype)

        if os.path.isfile(common.cur_file_dir() + '\\temp\\' + str(docid) +
                          '.pdf'):
            os.remove(common.cur_file_dir() + '\\temp\\' + str(docid) + '.pdf')
        return result
    elif formtype == 'HTML':
        doc_text = fo.get_doc_conent(docid,
                                     idtype='DocumentId',
                                     source='MDL',
                                     method=2)
        result = keyword_count(docid, kw_list, keywordtype, doc_text, formtype)
        return result
    else:  # txt
        doc_text = str(doc_data)
        result = keyword_count(docid, kw_list, keywordtype, doc_text, formtype)
        return result
예제 #2
0
def get_pdf_text(docid, file):
    pdftotext = common.cur_file_dir() + '\\static\\pdftotext.exe'
    output = common.cur_file_dir() + '\\temp\\' + docid + '.txt'
    cmd = pdftotext + ' -raw -enc UTF-8 ' + file + ' ' + output
    os.system(cmd)
    time.sleep(2)
    try:
        with open(output, 'r', encoding='UTF-8') as text_reader:
            text = text_reader.read()
    except:
        time.sleep(5)
        try:
            with open(output, 'r', encoding='UTF-8') as text_reader:
                text = text_reader.read()
        except:
            text = ''
    if os.path.isfile(output):
        os.remove(output)
    return text
예제 #3
0
 def __init__(self):
 # create Pinyin dict
     self.dic_py = dict()
     try:
         f_py = open(common.cur_file_dir()+'/py.dat',"r")
     except:
         return None
     content_py = f_py.read()
     lines_py = content_py.split('\n')
     n=len(lines_py)
     for i in range(0,n-1):
         word_py, mean_py = lines_py[i].split('\t', 1)#将line用\t进行分割,最多分一次变成两块,保存到word和mean中去
         self.dic_py[word_py]=mean_py
     f_py.close()
import apk_build

sys.path.append('./common')
import common

# listChannel = [source.XIAOMI, source.TAPTAP, source.HUAWEI, source.GP]
listChannel = [source.HUAWEI, source.TAPTAP, source.XIAOMI, source.GP]
# listChannel = [source.HUAWEI, source.TAPTAP, source.XIAOMI]



# 主函数的实现
if __name__ == "__main__":

    print ("脚本名:", sys.argv[0])
    cmdPath = common.cur_file_dir()
    count = len(sys.argv)
    isHD = False

    for i in range(1, count):
        print ("参数", i, sys.argv[i])
        if i == 1:
            cmdPath = sys.argv[i]

        if i == 2:
            if sys.argv[i] == "hd":
                isHD = True

    common.SetCmdPath(cmdPath)

    android_studio_dir = common.GetRootDirAndroidStudio()
예제 #5
0
def run(id, SupplementDocType):
    try:
        # By doc from CIK
        connection = pyodbc.connect(common.connection_string_multithread)
        code1 = '''
			select Comment as a
				from DocumentAcquisition..MasterProcess as mp
				where Comment is not null
				and Category=1
				and Status<>5
				and mp.ProcessId=%s
		''' % id
        cursor = connection.cursor()
        result1 = cursor.execute(code1).fetchall()

        if len(result1) > 0:
            a = result1[0][0]
            b = a[9:len(a) - 1]
            filingid = b
        else:
            code2 = '''
				select distinct fsc.FilingId
				from DocumentAcquisition..FilingSECContract as fsc
				left join DocumentAcquisition..MasterProcess as mp on fsc.FilingId=mp.ContainerId
				where mp.ProcessId=%s
			''' % id
            result2 = cursor.execute(code2).fetchall()
            filingid = result2[0][0]
        code = '''
			Declare
			@SupplementDocType int
			Set @SupplementDocType=%s
			select distinct fb.LegalName
			--CONVERT(varchar(10),mp.EffectiveDate,120) as [EffectiveDate]
			from
			(select A.FilingId,A.CIK ,ii.InvestmentId
			from
			(
			select distinct fsc.FilingId,fsc.CIK
			from DocumentAcquisition..FilingSECContract as fsc
			where fsc.FilingId in(%s)
			) as A
			left join DocumentAcquisition..FilingSECContract as fsc2 on fsc2.CIK=A.CIK
			left join CurrentData..InvestmentIdentifier as ii on ii.Identifier=fsc2.ContractId and ii.IdentifierType=20
			left join SecurityData..SecuritySearch as ss on ss.SecId=ii.InvestmentId
			where ss.Status<>0) as B
			left join DocumentAcquisition..SECCurrentDocument as scd on scd.InvestmentId=B.InvestmentId
			left join DocumentAcquisition..MasterProcess as mp on mp.DocumentId=scd.DocumentId
			left join DocumentAcquisition..SECFiling as sf on sf.FilingId=mp.ContainerId
			left join DocumentAcquisition..InvestmentMapping as im on im.ProcessId=mp.ProcessId
			left join SecurityData..SecuritySearch as SS on SS.SecId=im.InvestmentId
			left join [CurrentData].[dbo].[FundBasic]as fb on fb.FundId=SS.FundId ---找到Legalname
			left join DocumentAcquisition..SystemParameter as sp on sp.CodeInt=mp.DocumentType and sp.CategoryId=105
			where mp.DocumentType=case when @SupplementDocType=2  then 1--supplement=2
									   when @SupplementDocType=15 then 3-----supplement to SAI=15
									   when @SupplementDocType=60 then 17-----Sup to Summary Prospectus=60
									   end

			and SS.Status<>0
			group by
			fb.LegalName
			order by fb.LegalName
		''' % (SupplementDocType, filingid)
        cursor = connection.cursor()
        result = cursor.execute(code).fetchall()
        LegalName = []
        for item in result:
            LegalName.append(item[0].title())

        # Extract Content Fund
        Doctext = fo.get_doc_conent(id,
                                    idtype='ProcessId',
                                    source='DAP',
                                    method=1)
        reglex = re.compile(
            '\\s(?:[0-9A-Z&][^,\\"@\\s\\n\\r\\t]*?\\s{1,2}){1,10}?(?:Fund|ETF|Portfolio|Reserves|RESERVES|FUND|PORTFOLIO|VP|VIP)\\b'
        )
        Funds = re.findall(reglex, Doctext)
        # 去重
        Funds = list(set(Funds))

        with open(
                common.cur_file_dir() +
                '\\static\\SearchContentFund\\invalid_fund.txt', 'r') as e:
            msgs = e.read()
            invalid = msgs.split(',')
        Filter_Funds = [
            Fund.title().strip() for Fund in Funds if Fund not in invalid
        ]

        # 根据匹配度进行排序
        test = []
        while len(Filter_Funds) != 0 and len(LegalName) != 0:
            temps = []
            for a in Filter_Funds:
                for b in LegalName:
                    ratio = compare_ratio(a, b)
                    lst = [a, b, ratio]
                    temps.append(lst)
            temps.sort(key=lambda temp: temp[2], reverse=True)
            test.append(temps[0])
            LegalName.remove(temps[0][1])
            Filter_Funds.remove(temps[0][0])
        No_match = [
            row1 for row1 in LegalName if row1 not in [row[1] for row in test]
        ]
        No_match_fundlist = [['', row, 0] for row in No_match]
        final_result = test + No_match_fundlist

        # 输出html结果
        a = pd.DataFrame.from_records(
            data=final_result,
            columns=['ContentFund', 'LegalName',
                     'Diff Ratio']).sort_values(by='Diff Ratio',
                                                ascending=False)
        pd.set_option('display.max_colwidth', -1)
        html_code = a.to_html(classes='tablestyle', index=False)
        html_code = common.css_code + html_code
        return html_code
    except Exception as e:
        return 'Error: ' + str(e)
예제 #6
0

def remove_head(x):
    if x[0] == '-':
        x = x[1:]
    if x[1] == '-':
        x = x[2:]
    if x[2] == '-':
        x = x[3:]
    if x[0] == ' ':
        x = x[1:]
    return x


Umbrella_dict = {}
with open(common.cur_file_dir() +
          '\\static\\Rename_Tool_dicts\\Umbrella_dict.txt',
          'r',
          encoding='UTF-8') as r_d:
    for line in r_d.readlines():
        list1 = line.split('#')
        a = str(list1[0].strip('\n'))
        b = str(list1[1].strip('\n'))
        Umbrella_dict[a] = b

Fund_dict_Abbr_1 = {}
with open(common.cur_file_dir() +
          '\\static\\Rename_Tool_dicts\\Fund_dict_Abbr_1.txt',
          'r',
          encoding='UTF-8') as r_d:
    if r_d.read() == '':
예제 #7
0
def run(ids, idtype, keywords, keywordtype, ThreadNumber):
    try:
        result_file = 'Reslut-' + time.strftime('%Y%m%d') + time.strftime(
            '%H%M%S') + '.csv'
        result_path = common.cur_file_dir() + '\\Results\\'

        id_list = []
        ids1 = ids.split('\n')
        for line in ids1:
            if len(line) > 0:
                line = line.strip()
                line = line.strip('\r')
                id_list.append(line)

        keyword_list = []
        kw1 = keywords.split('\n')
        for line in kw1:
            if len(line) > 0:
                # line = line.strip()
                line = line.rstrip('\r')
                keyword_list.append(line)

        if not os.path.exists(result_path):
            os.makedirs(result_path)

        totalThread = ThreadNumber
        total_result = []

        num = len(id_list)
        if num < int(totalThread):
            totalThread = num
        gap = int(float(num) / float(totalThread))

        mutex = threading.Lock()
        threadlist = [
            threading.Thread(target=getrange,
                             args=(
                                 i,
                                 i + gap,
                                 id_list,
                                 idtype,
                                 keyword_list,
                                 keywordtype,
                                 ThreadNumber,
                                 mutex,
                                 total_result,
                                 num,
                             )) for i in range(0, num, gap)
        ]
        for t in threadlist:
            t.setDaemon(True)
            t.start()
        for i in threadlist:
            i.join()

        df = pd.DataFrame(total_result,
                          columns=['Id', 'KeyWord', 'Count', 'Format', ' '])

        try:
            if os.path.isfile(result_path + result_file):
                os.remove(result_path + result_file)
            df.to_csv(result_path + result_file, encoding='UTF-8')
        except:
            if os.path.isfile(result_path + result_file):
                os.remove(result_path + result_file)
            df.to_csv(result_path + result_file, encoding='GB18030')

        return (result_path, result_file)
    except Exception as e:
        return str(e)
예제 #8
0
    def __init__(self, parent, uname, upass, dpool, epool):
        # begin wxGlade: MainPannel.__init__
        self.version = 1.0
        self.canlock = True
        self.listall = False
        self.last_copied_pass = None
        wx.Frame.__init__(self,
                          parent,
                          size=(1000, 1000),
                          style=wx.TAB_TRAVERSAL | wx.DEFAULT_FRAME_STYLE
                          | wx.WANTS_CHARS)
        self.DWorkerPool = dpool
        self.EWrokerPool = epool
        self.uname = uname
        self.upass = upass
        self.icon = wx.Icon(
            os.path.join(common.cur_file_dir(), "manpassc.ico"),
            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)
        #self.chkupdate_thread=checkUpdate.ChkUpdateThread("http://192.168.1.1:8090/ver.txt",self.version,self)

        #username, password must be encoded into utf-8 string before they could be used by crypto functions
        self.lock_label = wx.HyperlinkCtrl(self,
                                           wx.ID_ANY,
                                           _("Unlock Me"),
                                           style=wx.HL_ALIGN_CENTRE)
        self.progress_bar = wx.Gauge(self, wx.ID_ANY)
        self.status_bar = wx.StatusBar(self, wx.ID_ANY)
        self.SetStatusBar(self.status_bar)

        defconflist = [
            (_("Basic Options"), [
                (("addr"), {
                    "desc": _("Listening address"),
                    "value": "127.0.0.1",
                    "type": "string"
                }),
                (("port"), {
                    "desc": _("Listening port"),
                    "value": 9000,
                    "type": "int"
                }),
                (("idle_timer"), {
                    "desc": _("Idle lock timer(seconds)"),
                    "value": 60,
                    "type": "int"
                }),
                (("startup_minimize"), {
                    "desc": _("Minimize the window upon startup"),
                    "value": False,
                    "type": "bool"
                }),
                (("close&lock"), {
                    "desc": _("Lock the window upon close(windows only)"),
                    "value": True,
                    "type": "bool"
                }),
            ]),
        ]
        self.OptionDiag = myoptions.OptionDiag(self, "manpass.conf",
                                               defconflist, self.uname)
        self.confDict = None
        self.confDict = self.OptionDiag.toDict()
        if not common.checkTCPPort(self.confDict['addr'],
                                   self.confDict['port']):
            waitbox = wx.BusyInfo(_("Starting Manpass server, please wait..."))
            cmd = common.getManpassdExeName()
            exename = cmd
            cmd += " -username={uname} -pipepass=true -svrip={ip} -svrport={port}".format(
                uname=self.uname,
                ip=self.confDict['addr'],
                port=self.confDict['port'])
            args = shlex.split(cmd)
            if platform.system() == "Windows":
                startupinfo = subprocess.STARTUPINFO()
                startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
            else:
                startupinfo = None
            try:
                self.svrp = subprocess.Popen(args,
                                             executable=exename,
                                             stdin=subprocess.PIPE,
                                             stdout=subprocess.PIPE,
                                             stderr=subprocess.PIPE,
                                             shell=False,
                                             startupinfo=startupinfo)
            except Exception as Err:
                del waitbox
                wx.MessageBox(unicode(Err), _("Error"), 0 | wx.ICON_ERROR,
                              self)
                self.ExitMe()
                return

            def enqueue_output(out, queue):
                for line in iter(out.readline, b''):
                    queue.put(line)
                out.close()

            errq = Queue.Queue()
            t2 = newUserDiag.EnQThread(self.svrp.stderr, errq)
            t2.daemon = True
            t2.start()
            self.svrp.stdin.write(self.upass + "\n")
            self.svrp.stdin.close()
            ferror = False
            ferror_msg = ""

            def check_output(errq):
                t0 = time.time()
                ferror = False
                while True:
                    wx.GetApp().Yield()
                    try:
                        errline = errq.get_nowait()
                    except Queue.Empty:
                        if time.time() - t0 > 30.0:
                            ferror = True
                            ferror_msg = "Time out"
                            break
                        pass
                    else:
                        if errline.find("Server started") != -1:
                            break
                        if errline.find("Fatal Error") != -1:
                            ferror = True
                            ferror_msg = errline
                            break
                        if (time.time() - t0) > 30.0:
                            ferror = True
                            ferror_msg = "Time out"
                            break
                t2.stop()
                if ferror:
                    ##                    wx.MessageBox(_("Server failed to start!\n")+unicode(ferror_msg),_("Error"),0|wx.ICON_ERROR,self)
                    return _("Server failed to start!\n") + unicode(ferror_msg)
                else:
                    return True

            startresult = check_output(errq)
            if startresult != True:
                del waitbox
                wx.MessageBox(startresult, _("Error"), 0 | wx.ICON_ERROR, self)
                self.ExitMe()
                return
            del waitbox

        try:
            cadata = apiclient.loadCAFile(self.uname, self.upass,
                                          self.confDict['confDir'])
        except Exception as Err:
            wx.MessageBox(
                _("Authentication Failed!\n") + unicode(Err), _("Error"),
                0 | wx.ICON_ERROR, self)
            self.ExitMe()
            return
        try:
            self.apiclient = apiclient.APIClient(
                self.confDict['addr'], self.confDict['port'], cadata,
                os.path.join(self.confDict["confDir"], "ee.cert"),
                os.path.join(self.confDict["confDir"], "ee.key"), self.upass,
                self.DWorkerPool, self.EWrokerPool)
        except Exception as Err:
            ##            traceback.print_exc(Err)
            wx.MessageBox(_("Failed to connect to the server!"), _("Error"),
                          0 | wx.ICON_ERROR, self)
            self.ExitMe()
            return

        self.SetTitle("Manpass - " + self.uname.decode("utf-8"))

        if platform.system() == "Windows":
            self.taskicon = MyTaskbarIcon(self)
            self.taskicon.SetIcon(self.icon)
            wx.EVT_TASKBAR_LEFT_UP(self.taskicon, self.OnDClickTaskIcon)

        self.Bind(wx.EVT_CLOSE, self.HideMe)

        self.timer_lock = wx.Timer(self, wx.NewId())
        self.timer_clear = wx.Timer(self, wx.NewId())
        self.timer_statustxt = wx.Timer(self, wx.NewId())
        self.timer_lock.Start(self.confDict['idle_timer'] * 1000,
                              wx.TIMER_CONTINUOUS)
        self.text_ctrl_search_input = wx.SearchCtrl(self, wx.NewId(), "")
        self.list_ctrl_1 = PassListCtrl(self, self.text_ctrl_search_input)

        self.Bind(wx.EVT_TIMER, self.OnTimerLock, self.timer_lock)
        self.Bind(wx.EVT_TIMER, self.OnTimerClear, self.timer_clear)
        self.Bind(wx.EVT_TIMER, self.OnTimerStatusTxt, self.timer_statustxt)

        self.Bind(wx.EVT_TEXT, self.OnFilter, self.text_ctrl_search_input)
        self.text_ctrl_search_input.Bind(wx.EVT_SET_FOCUS, self.OnFilterAct)
        self.text_ctrl_search_input.Bind(wx.EVT_CHAR, self.OnChar)

        self.Bind(wx.EVT_CHAR, self.OnChar)
        self.list_ctrl_1.Bind(wx.EVT_CHAR, self.OnChar)
        self.lock_label.Bind(wx.EVT_CHAR, self.OnChar)
        ##        self.text_ctrl_search_input.Bind(wx.EVT_SET_FOCUS,self.OnFilterAct)

        self.__set_properties()
        self.__do_layout()
        self.CentreOnScreen()
        self.SetSize((400, 400))
        self.list_ctrl_1.reload()
        self.text_ctrl_search_input.SetFocus()
        self.text_ctrl_search_input.SetValue("")

        #self.Bind(wx.EVT_ICONIZE,self.HideMe)
        self.lock_label.Bind(wx.EVT_HYPERLINK, self.OnUnlock)

        #self.text_ctrl_search_input.Bind(wx.EVT_CHAR,self.resetTimer)

        self.list_ctrl_1.Bind(wx.dataview.EVT_DATAVIEW_SELECTION_CHANGED,
                              self.resetTimer)
        self.list_ctrl_1.Bind(wx.dataview.EVT_DATAVIEW_ITEM_ACTIVATED,
                              self.resetTimer)
        self.list_ctrl_1.Bind(wx.dataview.EVT_DATAVIEW_COLUMN_HEADER_CLICK,
                              self.resetTimer)
        self.list_ctrl_1.Bind(
            wx.dataview.EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK,
            self.resetTimer)
        self.list_ctrl_1.Bind(wx.dataview.EVT_DATAVIEW_ITEM_CONTEXT_MENU,
                              self.resetTimer)
        self.Bind(wx.EVT_ACTIVATE, self.resetTimer)
        self.Bind(common.EVT_MANPASS_FATALERR, self.OnFatal)
        self.Bind(common.EVT_MANPASS_PROGRESS, self.UpdateProgress)
        self.Bind(common.EVT_MANPASS_LOAD_DONE, self.LoadDone)
        self.Bind(wx.EVT_SET_FOCUS, self.OnFocus)
        #self.Bind(checkUpdate.EVT_CHK_UPDATE,self.CheckUpdateDone)

        if platform.system() == "Windows":
            import win32con
            self.RegisterHotKey(52445, win32con.MOD_CONTROL, ord("I"))
            self.Bind(wx.EVT_HOTKEY, self.OnDClickTaskIcon, id=52445)

        if self.confDict['startup_minimize']:
            self.HideMe(None)
        else:
            self.Show(True)
            self.Raise()
예제 #9
0
 def OnHelp(self, evt):
     url = "file://" + common.cur_file_dir() + '/help.htm'
     webbrowser.open_new_tab(url)
예제 #10
0
    def __init__(self, parent,uname,upass,dpool,epool):
        # begin wxGlade: MainPannel.__init__
        self.version=1.0
        self.canlock=True
        self.listall=False
        self.last_copied_pass=None
        wx.Frame.__init__(self,parent,size=(1000,1000),style=wx.TAB_TRAVERSAL|wx.DEFAULT_FRAME_STYLE|wx.WANTS_CHARS)
        self.DWorkerPool=dpool
        self.EWrokerPool=epool
        self.uname=uname
        self.upass=upass
        self.icon=wx.Icon(os.path.join(common.cur_file_dir(),"manpassc.ico"),wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        #username, password must be encoded into utf-8 string before they could be used by crypto functions
        self.lock_label=wx.HyperlinkCtrl(self,wx.ID_ANY,_("Unlock Me"),style=wx.HL_ALIGN_CENTRE)
        self.progress_bar=wx.Gauge(self,wx.ID_ANY)
        self.status_bar=wx.StatusBar(self,wx.ID_ANY)
        self.SetStatusBar(self.status_bar)

        defconflist=[
        (_("Basic Options"),
                [(("addr"),{"desc":_("Listening address"),"value":"127.0.0.1","type":"string"}),
                 (("port"),{"desc":_("Listening port"),"value":9000,"type":"int"}),
                 (("idle_timer"),{"desc":_("Idle lock timer(seconds)"),"value":60,"type":"int"}),
                 (("startup_minimize"),{"desc":_("Minimize the window upon startup"),"value":False,"type":"bool"}),
                 (("close&lock"),{"desc":_("Lock the window upon close(windows only)"),"value":True,"type":"bool"}),
                    ]
            ),
        ]
        self.OptionDiag=myoptions.OptionDiag(self,"manpass.conf",defconflist,self.uname)
        self.confDict=None
        self.confDict=self.OptionDiag.toDict()
        if not common.checkTCPPort(self.confDict['addr'],self.confDict['port']):
            waitbox=wx.BusyInfo(_("Starting Manpass server, please wait..."))
            cmd=common.getManpassdExeName()
            exename=cmd
            cmd+=" -username={uname} -pipepass=true -svrip={ip} -svrport={port}".format(uname=self.uname,ip=self.confDict['addr'],port=self.confDict['port'])
            args=shlex.split(cmd)
            if platform.system()=="Windows":
                startupinfo = subprocess.STARTUPINFO()
                startupinfo.dwFlags|= subprocess.STARTF_USESHOWWINDOW
            else:
                startupinfo = None
            try:
                self.svrp=subprocess.Popen(args,executable=exename, stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=False,startupinfo=startupinfo)
            except Exception as Err:
                del waitbox
                wx.MessageBox(unicode(Err),_("Error"),0|wx.ICON_ERROR,self)
                self.ExitMe()
                return

            def enqueue_output(out, queue):
                for line in iter(out.readline, b''):
                    queue.put(line)
                out.close()
            errq=Queue.Queue()
            t2=newUserDiag.EnQThread(self.svrp.stderr,errq)
            t2.daemon=True
            t2.start()
            self.svrp.stdin.write(self.upass+"\n")
            self.svrp.stdin.close()
            ferror=False
            ferror_msg=""
            def check_output(errq):
                t0=time.time()
                ferror=False
                while True:
                    wx.GetApp().Yield()
                    try:
                        errline=errq.get_nowait()
                    except Queue.Empty:
                        if time.time()-t0>30.0:
                            ferror=True
                            ferror_msg="Time out"
                            break
                        pass
                    else:
                        if errline.find("Server started")!=-1:
                            break
                        if errline.find("Fatal Error")!=-1:
                            ferror=True
                            ferror_msg=errline
                            break
                        if (time.time()-t0)>30.0:
                            ferror=True
                            ferror_msg="Time out"
                            break
                t2.stop()
                if ferror:
##                    wx.MessageBox(_("Server failed to start!\n")+unicode(ferror_msg),_("Error"),0|wx.ICON_ERROR,self)
                    return _("Server failed to start!\n")+unicode(ferror_msg)
                else:
                    return True
            startresult=check_output(errq)
            if startresult!=True:
                del waitbox
                wx.MessageBox(startresult,_("Error"),0|wx.ICON_ERROR,self)
                self.ExitMe()
                return
            del waitbox

        try:
            cadata=apiclient.loadCAFile(self.uname,self.upass,self.confDict['confDir'])
        except Exception as Err:
            wx.MessageBox(_("Authentication Failed!\n")+unicode(Err),_("Error"),0|wx.ICON_ERROR,self)
            self.ExitMe()
            return
        try:
            self.apiclient=apiclient.APIClient(self.confDict['addr'],self.confDict['port'],cadata,
            os.path.join(self.confDict["confDir"],"ee.cert"),
            os.path.join(self.confDict["confDir"],"ee.key"),self.upass,
            self.DWorkerPool,self.EWrokerPool)
        except Exception as Err:
##            traceback.print_exc(Err)
            wx.MessageBox(_("Failed to connect to the server!"),_("Error"),0|wx.ICON_ERROR,self)
            self.ExitMe()
            return

        self.SetTitle("Manpass - "+self.uname.decode("utf-8"))

        if platform.system()=="Windows":
            self.taskicon=MyTaskbarIcon(self)
            self.taskicon.SetIcon(self.icon)
            wx.EVT_TASKBAR_LEFT_UP(self.taskicon,self.OnDClickTaskIcon)

        self.Bind(wx.EVT_CLOSE,self.HideMe)


        self.timer_lock=wx.Timer(self,wx.NewId())
        self.timer_clear=wx.Timer(self,wx.NewId())
        self.timer_statustxt=wx.Timer(self,wx.NewId())
        self.timer_lock.Start(self.confDict['idle_timer']*1000,wx.TIMER_CONTINUOUS)
        self.text_ctrl_search_input = wx.SearchCtrl(self, wx.NewId(),"")
        self.list_ctrl_1 = PassListCtrl(self,self.text_ctrl_search_input)


        self.Bind(wx.EVT_TIMER,self.OnTimerLock,self.timer_lock)
        self.Bind(wx.EVT_TIMER,self.OnTimerClear,self.timer_clear)
        self.Bind(wx.EVT_TIMER,self.OnTimerStatusTxt,self.timer_statustxt)

        self.Bind(wx.EVT_TEXT,self.OnFilter,self.text_ctrl_search_input)
        self.text_ctrl_search_input.Bind(wx.EVT_SET_FOCUS,self.OnFilterAct)
        self.text_ctrl_search_input.Bind(wx.EVT_CHAR,self.OnChar)

        self.Bind(wx.EVT_CHAR,self.OnChar)
        self.list_ctrl_1.Bind(wx.EVT_CHAR,self.OnChar)
        self.lock_label.Bind(wx.EVT_CHAR,self.OnChar)
##        self.text_ctrl_search_input.Bind(wx.EVT_SET_FOCUS,self.OnFilterAct)

        self.__set_properties()
        self.__do_layout()
        self.CentreOnScreen()
        self.SetSize((400,400))
        self.list_ctrl_1.reload()
        self.text_ctrl_search_input.SetFocus()
        self.text_ctrl_search_input.SetValue("")


        #self.Bind(wx.EVT_ICONIZE,self.HideMe)
        self.lock_label.Bind(wx.EVT_HYPERLINK,self.OnUnlock)

        #self.text_ctrl_search_input.Bind(wx.EVT_CHAR,self.resetTimer)

        self.list_ctrl_1.Bind(wx.dataview.EVT_DATAVIEW_SELECTION_CHANGED,self.resetTimer)
        self.list_ctrl_1.Bind(wx.dataview.EVT_DATAVIEW_ITEM_ACTIVATED,self.resetTimer)
        self.list_ctrl_1.Bind(wx.dataview.EVT_DATAVIEW_COLUMN_HEADER_CLICK,self.resetTimer)
        self.list_ctrl_1.Bind(wx.dataview.EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK,self.resetTimer)
        self.list_ctrl_1.Bind(wx.dataview.EVT_DATAVIEW_ITEM_CONTEXT_MENU,self.resetTimer)
        self.Bind(wx.EVT_ACTIVATE,self.resetTimer)
        self.Bind(common.EVT_MANPASS_FATALERR,self.OnFatal)
        self.Bind(common.EVT_MANPASS_PROGRESS,self.UpdateProgress)
        self.Bind(common.EVT_MANPASS_LOAD_DONE,self.LoadDone)
        self.Bind(wx.EVT_SET_FOCUS,self.OnFocus)

        if platform.system()=="Windows":
            import win32con
            self.RegisterHotKey(52445,win32con.MOD_CONTROL,ord("I"))
            self.Bind(wx.EVT_HOTKEY, self.OnDClickTaskIcon, id=52445)


        if self.confDict['startup_minimize']:
            self.HideMe(None)
        else:
            self.Show(True)
            self.Raise()
예제 #11
0
 def OnHelp(self,evt):
     url="file://"+common.cur_file_dir()+'/help.htm'
     webbrowser.open_new_tab(url)