ó à@Qc@sVddlZddlZddlZyddlmZWnek rWddlZnXddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZmZddlmZddlmZmZmZddlZdad„Zd„Zd „Zd „Zd „Zd „Zd „Zd„Zdd„Z dd„Z!dd„Z"d„Z#d„Z$d„Z%d„Z&dd+d„ƒYZ'de j(fd„ƒYZ)d„Z*d„Z+d„Z,d„Z-d „Z.d!„Z/d"efd#„ƒYZ0d$d%ddd&d'„Z2d(„Z3d)„Z4e5d*krRe4ej6d%ƒndS(,iÿÿÿÿN(tdbapi2(tBaseHTTPRequestHandlert HTTPServer(turlparse(tcurdirtseptmakedirss./cCs dG|GHdS(sLog an error message.sError: N((t messagetext((s..\modules\mysqldoclib.pyt log_errorscCs |GHdS(sLog a general message.N((R((s..\modules\mysqldoclib.pyt log_messagescCs|r|GHndS(s1Output a general message if verbose is turned on.N((tverboseR((s..\modules\mysqldoclib.pyt verbose_printscCs†tjjdƒr'tjjdƒ}n9tjjdƒrNtjjdƒ}ntjjdƒ}tjj|ƒs‚tj|ƒn|S(Ntdarwins/~/Library/Application Support/MySQL/DocLibrary/twins${APPDATA}/MySQL/DocLibrary/s~/.mysql/DocLibrary/( tsystplatformt startswithtostpatht expandusert expandvarstexistsR(R((s..\modules\mysqldoclib.pytget_app_data_dir'scCsAtjjtƒdƒ}tjj|ƒr.|StjjtdƒS(Nsmysqldoclib.sqlite(RRtjoinRRtglobal_app_data_dir(R((s..\modules\mysqldoclib.pytget_lib_db_path4scCsAtjjtƒdƒ}tjj|ƒr.|StjjtdƒS(Nsmysqldoclib_webui.sqlite(RRRRRR(R((s..\modules\mysqldoclib.pytget_webui_db_path;scCs>tjjtƒdƒ}tjj|ƒs:yÝtj|ƒ}z¼y”|jƒ}zv|jdƒ|jdƒ|jdƒ|jdƒ|jdƒ|jdƒ|jdƒ|jd ƒ|j ƒWd|j ƒXWn!t k rö}t d |ƒnXWd|j ƒXWq:t k r6}t d ||fƒ|‚q:Xn|S( Nsmysqldoclib_usr.sqlitesþ CREATE TABLE IF NOT EXISTS page_rating ( id_page_rating INTEGER PRIMARY KEY AUTOINCREMENT, id_manual_type INTEGER NOT NULL, title TEXT NOT NULL, rating INTEGER )s@CREATE INDEX IF NOT EXISTS idx_page_rating ON page_rating(title)sÆ CREATE TABLE IF NOT EXISTS page_view ( id_page_view INTEGER PRIMARY KEY AUTOINCREMENT, path TEXT NOT NULL, hits INTEGER )s;CREATE INDEX IF NOT EXISTS idx_page_view ON page_view(path)sÏ CREATE TABLE IF NOT EXISTS lib_search ( id_lib_search INTEGER PRIMARY KEY AUTOINCREMENT, search_text TEXT NOT NULL, hits INTEGER )sDCREATE INDEX IF NOT EXISTS idx_lib_search ON lib_search(search_text)sí CREATE TABLE IF NOT EXISTS lib_status ( id_lib_file INTEGER PRIMARY KEY AUTOINCREMENT, id_lib INTEGER, downloaded INTEGER, is_selected INTEGER )sHINSERT INTO lib_status(id_lib, downloaded, is_selected) VALUES (1, 1, 1)s)Error while creating the usr database. %rs;An error occurred while creating the usr database at %s. %r( RRRRRtsqlite3tconnecttcursortexecutetcommittcloset ExceptionR(Rtdb_conntcte((s..\modules\mysqldoclib.pytget_user_db_pathAs:      cCsdS(Ns./((((s..\modules\mysqldoclib.pytget_module_installation_dir{ssutf-8cCs…y]tj|d|ƒ}z6y|jƒSWn!tk rL}td|ƒnXWd|jƒXWn!tk r€}td|ƒnXdS(s Read the contents of a text filetrs+An error occurred reading from the file %s.Ns&An error occurred opening the file %s.(tcodecstopentreadR!RR (tfilenametencodingtfR$((s..\modules\mysqldoclib.pytread_file_content~scCsˆy`tj|d|ƒ}z9y|j|ƒWn!tk rO}td|ƒnXWd|jƒXWn!tk rƒ}td|ƒnXdS(s Read the contents of a text filetws+An error occurred reading from the file %s.Ns&An error occurred opening the file %s.(R(R)twriteR!RR (R+tcontentR,R-R$((s..\modules\mysqldoclib.pytsave_file_contentssUTF-8cCs¨t||ƒ}|stSyf|jƒ}zHy|j|ƒ|jƒtSWn"tk rn}td|ƒtSXWd|jƒXWn"tk r£}td|ƒtSXdS(sExecutes a SQL script files4An error occurred while executing the SQL script. %rNs0An error occurred aquiring a database cursor. %r( R.tFalseRt executescriptRtTrueR!RR (R"R+R,t sql_commandsR#R$((s..\modules\mysqldoclib.pytexecute_sql_scriptŸs"    cCstjdƒ}|jd|ƒS(s)Removes all HTML tags from a given strings <[^<]*?/?>t (tretcompiletsub(tdatatp((s..\modules\mysqldoclib.pythtml_remove_tags¾scCstjdƒ}|jd|ƒS(s,Removes all extra spaces from a given strings\s+R8(R9R:R;(R<R=((s..\modules\mysqldoclib.pythtml_remove_extra_spacesÄscCstjdƒ}|j|ƒ}|r@|jdƒ|jdƒfStjdƒ}|j|ƒ}|rwd|jdƒfSdSdS(s:Returns the chapter and title of a manual html page stringsJ\(?P(Chapter\s)?[A-Z]?[\d\.]+)\s*(?P.*)\<\/title\>t���Chaptert���Titles!���\<title\>(?P<Title>.*)\<\/title\>t����N(���RB���RB���(���R9���R:���t���searcht���group(���R<���R=���t���match(����(����s���..\modules\mysqldoclib.pyt���html_get_page_titleÉ���s����c���������C���sF���t��j�d�ƒ�}�|�j�d�|��ƒ�}��t��j�d�ƒ�}�|�j�d�|��ƒ�}��|��S(���s!���Make required changes to the htmls ���\<\/title\>sT���s\starget=\"_top\"RB(R9R:R;(R<R=((s..\modules\mysqldoclib.pythtml_apply_page_modificationsØs tManualPageDatacBs,eZdZdZdZdZdZdZRS(s5Data class that holds information about a manual pageRB(t__name__t __module__t__doc__R+ttitletchapterR1t html_content(((s..\modules\mysqldoclib.pyRHás tScanManualPageThreadcBs#eZdZdZdZd„ZRS(iRBcCsøyÝxÖtrÛ|jjtƒ}y•|jj|ƒ}t|jƒdƒ}|sTwntƒ}||_ t |ƒ\|_ |_ t t|ƒƒ|_t|ƒ|_|jj|ƒWqtk r×}td|ƒPqXqWWntjk rónXdS(Nsutf-8s An error processing the page. %r(R5tfilename_queuetgetR3t lib_zip_fileR)tunicodeR*RHR+RFRMRLR?R>R1RGRNtmanual_page_data_queuetputR!RtQueuetEmpty(tselfR+t html_filet html_stringtmanual_page_dataR$((s..\modules\mysqldoclib.pytrunís&    (RIRJRPRTRRR\(((s..\modules\mysqldoclib.pyROésc Csay9|jƒ}d}xtr3yú|jtƒ} yº|jdd|dtjj| jƒd| j dgƒ|jd||j | j | j gƒ|jd|j | j | j gƒ|d7}|ddkrétd |||fƒnWn*tk r} td | j| fƒnXWqtjk r/PqXqW|SWn!tk r\} td | ƒnXdS( NispINSERT OR REPLACE INTO web_object(path, content_type, content, allow_embedded_code_execution) VALUES(?, ?, ?, ?)t/s text/htmlsNINSERT INTO page(id_manual, id_web_object, title, chapter) VALUES (?, ?, ?, ?)sBINSERT INTO page_content(id_page, title, content) VALUES (?, ?, ?)iids%d file(s) of %d processed...s<An error occurred while inserting the page values for %s. %rs0An error occurred aquiring a database cursor. %r(RR5RQR3RRRtbasenameR+RNt lastrowidRLRMR1R R!RRVRW( R"RRRt id_manualtfile_nrt file_countRTR#tfiles_processedR[R$((s..\modules\mysqldoclib.pytprocess_manual_page_data_queues.   1    c CsÛy³|jƒ}zEy|jdƒ|jƒ}Wn!tk rR}td|ƒnXWd|jƒXxM|D]E\}}}|r§t|ƒ|kr§td|ƒqiq§n|d}tj j tj j ddƒ|ƒ} tj j | ƒsûtd| ƒqintd| ƒt j | d ƒ} z…y]g| jƒD]!} | jƒjd ƒr.| ^q.} t| ƒ} d }td || fƒtjƒ}tjƒ}x| D]}|j|ƒqšWtjjƒ}g}xOtd ƒD]A}tƒ}||_||_| |_|j|ƒ|jƒqÓWxc|r}|t|| |||| |ƒ7}x4t|ƒD]&\}}|jƒrnqPn||=PqPWqW|t|| |||| |ƒ7}|jƒ}zZy2tjjƒj dƒ}|jd||fƒWn!tk r}td|ƒnXWd|jƒX|j!ƒtjjƒ|}td|| |j"|j#fƒg| jƒD]!} | jƒjdƒr^| ^q^} tdt| ƒƒxÔ| D]Ì}y¢|jƒ}yh| j$|ƒ}|j%ƒ}|sßw n|jdd|dtj j&|ƒdt'j(|ƒd gƒWn'tk rF}td||fƒnXWq tk rk}td|ƒq Xq W|j!ƒWn!tk rž}td|ƒnXWd| jƒXqiWWn!tk rÖ}td|ƒnXdS(Ns-- Select all manuals SELECT m.id_manual, m.directory, m.description FROM manual m ORDER BY m.id_manuals6An error occurred while executing the SQL commands. %rsSkipping manual %s.s.zipt.t repositorys The zip file %s cannot be found.sProcessing %s ...R's.htmlis,Caching manual %s, processing %d file(s) ...is%Y-%m-%dsBUPDATE manual SET installed=1, generation_date=? WHERE id_manual=?s5An error occurred while updating the manual entry. %rs3%d file(s) of %d processed. Duration %d.%d seconds.s.pngsProcessing %d image file(s) ...spINSERT OR REPLACE INTO web_object(path, content_type, content, allow_embedded_code_execution) VALUES(?, ?, ?, ?)R]s/images/s image/pngs7An error occurred while inserting the image file %s. %rs0An error occurred aquiring a database cursor. %r()RRtfetchallR!RR tstrR RRRRtzipfiletZipFiletnamelisttlowertendswithtlenRVRUtdatetimetnowtrangeRORPRTRRtappendtstartRdt enumeratetisAlivetstrftimeRtsecondst microsecondsR)R*R^RtBinary(R"t manual_idsR#trowsR$R`t directoryt descriptiontzip_filet zip_file_pathRRtfiletfilesRbRaRPRTR-t time_starttPooltitthreadtindext the_threadtgeneration_datet time_durationR+t image_filetimage_file_string((s..\modules\mysqldoclib.pyt cache_pages6s¦    $4          "  "    4    8cCs³y‹| s|dkr"tƒ}ntj|ƒ}zKtdƒt|dƒrqtdƒt||ƒtdƒn tdƒWd|jƒXWn!tk r®}td|ƒnXdS(NRBs/Creating the documentation library structure...s./mysqldoclib.sqls+Documentation library created successfully.s-Documentation library cached has been filled.s9The documentation library structure has not been created.s;An error occurred while opening the database connection. %r( RRRR R7RŒR R!R(R tdoclib_db_nameRzR"R$((s..\modules\mysqldoclib.pyt rebuild_libÅs     c CsAy| s|dkr"tƒ}ntj|ƒ}zÙtdƒt|dƒ|jƒ}zšx“tjdƒD]‚\}}}xp|D]h}|jdƒs³|jdƒs³|jdƒr%t tj j ||ƒƒ}|sÚq€ntd||fƒ|j d d |d tj j |ƒd |d gƒq€d} |jd ƒrCd} n0|jdƒr[d} n|jdƒrsd} nttj j ||ƒdƒ} td||fƒ|j d d |d tj j |ƒ| tj| jƒƒdgƒq€WqjWWd|jƒX|jƒWd|jƒXWn!tk r<} td| ƒnXdS(NRBs5Creating the documentation library webui structure...s./mysqldoclib_webui.sqltwebuis.htmls.wbps.csssPath: %s, File: %sspINSERT OR REPLACE INTO web_object(path, content_type, content, allow_embedded_code_execution) VALUES(?, ?, ?, ?)R]s text/htmlis.pngs image/pngs.gifs image/gifs.icosimage/vnd.microsoft.icontrbis;An error occurred while opening the database connection. %r(RRRR R7RRtwalkRmR.RRRR^R)RyR*R RR!R( R t webui_db_nameR"R#RtdirsRtnameRZt content_typetimg_fileR$((s..\modules\mysqldoclib.pyt rebuild_webuiàsD     - .    F cCsˆtjtƒƒ}yN|jƒ}z0|jdtƒfƒ|jdtƒfƒWd|jƒXWn!tk rƒ}t d|ƒnX|S(NsATTACH DATABASE ? AS webuisATTACH DATABASE ? AS usrs*Could not attach webui or usr database. %r( RRRRRRR%R R!R(R"R#R$((s..\modules\mysqldoclib.pyt open_lib_dbs cs‚idd6dd6dd6dd6d d 6‰d j‡fd †|Dƒƒ}|jd dƒjddƒ}d}yätƒ}zÉ|jƒ}|jd|fƒ|jƒ}|rÂ|jd|fƒn|jd|fƒ|jƒd|d}t|ƒdkr|dt|ƒd7}n|d7}zyÒ|j|ƒ|jƒ}|d7}|d|7}t |ƒdkrz|d7}n|dt |ƒ7}|d7}x]|D]U\}} } } } } }|d| d 7}||d!| d"7}|d#|d7}qŸWWn5t k r0}t d$|ƒ|d%t|ƒ7}nXWd|j ƒXWd|j ƒXWn!t k rs}t d&|ƒnX|d'7}|S((Ns&t&s"t"s't's>t>s<t0st;s\;s\'sü MySQL Workbench Documentation Library Search Result s5SELECT hits FROM usr.lib_search WHERE search_text = ?s?UPDATE usr.lib_search SET hits = hits + 1 WHERE search_text = ?s;INSERT INTO usr.lib_search (search_text, hits) VALUES(?, 1)s SELECT p.chapter, p.title, wpo.path, pr.rating, m.directory, offsets(page_content) as fs_offsets, snippet(page_content) as snippet FROM page_content pc JOIN page p ON p.id_page = pc.id_page JOIN manual m ON m.id_manual = p.id_manual JOIN web_object wpo ON p.id_web_object = wpo.id_web_object LEFT OUTER JOIN page_rating pr ON p.title = pr.title LEFT OUTER JOIN usr.page_rating pru ON p.title = pru.title WHERE page_content MATCH 'is AND m.id_manual = R8s_ ORDER BY pru.rating DESC, substr(fs_offsets, 1, 1), pr.rating DESC LIMIT 0, 51sC

MySQL Document Manual Search


s'Search Result for `%s` returned i2sHmore than 50 matches.
Only the first 50 matches are displayed.s%d matches.s


ss

s5An error occurred while executing the SQL command. %rs<
An error occurred while executing the SQL command.
%rs;An error occurred while opening the database connection. %rs ( RtreplaceR˜RRRgRtintRhRnR!RR (t search_stringt manual_typetsearch_string_htmlthtmlR"R#R{t sql_selectRMRLRtratingR|toffsetstsnippetR$((RŸs..\modules\mysqldoclib.pytbuild_search_result_page&s`          "tDocsLibHandlercBs;eZd„Zd„Zd„Zddd„Zd„ZRS(cCs‹y_|j}|dkrC|jdƒ|jddƒ|jƒdSt|ƒ}|j}d}|jdƒrvd}nx|jdƒrŽd }n`|jd ƒr¦d }nH|jd ƒr¾d }n0|jdƒrÖd}n|jdƒrîd}nt|ƒdkr^|jdƒrtd|jƒt gg|jj dƒD]}|j dƒ^q9D]\}}}||f^qRƒ} | dj ddƒj ddƒ} | dj ƒ} td| t| ƒfƒ|jdƒ|jd|ƒ|jƒ|jjt| t| ƒƒjdƒƒq^y#|jjjƒ} zÿyÃd} |jd ƒrMd!} n| jd"| d#|gƒ| jƒ}|rWxq|D]Ï\}}}|jdƒ|jd|ƒ|jƒ|jd$ƒrâ|jj|jdƒƒn|jj|ƒ| jd%|fƒ| jƒ}|r-| jd&|fƒn| jd'|fƒ|jjjƒqWn—y_ttt|ƒ}|jdƒ|jd|ƒ|jƒ|jj|jƒƒ|jƒWn5tk rí}|j d(d)|ƒt!d*|ƒnXWn5tk r&}|j d(d+|ƒt!d,|ƒnXWd| jƒXWq^tk rZ}t!d-|ƒq^XnWn%t"k r†|j d(d)|ƒnXdS(.NR]i-tLocations/webui/index.wbpRBs.htmls text/htmls.cssstext/csss.pngs image/pngs.gifs image/gifs.icosimage/vnd.microsoft.icons.wbpis search.wbps Query: %sR™t=RCt+R8s%22s"R¤s2Search started, search_string: %s, manual_type: %diÈs Content-typesutf-8s/webuiswebui.sc SELECT content_type, content, allow_embedded_code_execution FROM s)web_object WHERE path = ?stext/s-SELECT hits FROM usr.page_view WHERE path = ?s7UPDATE usr.page_view SET hits = hits + 1 WHERE path = ?s3INSERT INTO usr.page_view (path, hits) VALUES(?, 1)i”sFile Not Found: %ssFile not found. %rsAn error occurred. %rs5An error occurred while executing the SQL command. %rs;An error occurred while opening the database connection. %r(#Rt send_responset send_headert end_headersRRmRnR tquerytdicttsplitt partitionR¡tstripR¢twfileR0R«tencodetserverR"RRRRgRR)RRR*R R!t send_errorRtIOError(RXturl_fullt url_parsedturlR•tlinetktjunktvtdR£R¤R#tdatabaseR{two_content_typet wo_contentt wo_allow_embedded_code_executionR-R$((s..\modules\mysqldoclib.pytdo_GET…s˜            V"  +        c CsóyÂtj|jjdƒƒ\}}|dkr“td|jjƒƒd}|jjdƒr‡t|jdƒ}|jj |ƒ}n|jjdƒrÄd|jdkrÄ|j dd ƒ}qÄnt gg|j d ƒD]}|j d ƒ^qÚD]\}}}||f^qóƒ} | d jƒ} | d jƒ} td | t| ƒfƒ|jdƒ|jƒ|jjt| t| ƒƒjdƒƒn.|jdd|ƒ|jƒ|jjdƒWn*tk rî} t|jjd| ƒnXdS(Ns content-types text/plainsHeader Items: %sRBscontent-lengths user-agentt AppleWebKitR™s R®RCR¤s2Search started, search_string: %s, manual_type: %di-sutf-8i”sWrong content-types Wrong content-type

s=An Exception was raised while processing the POST handler. %r(tcgit parse_headertheaderst getheaderR titemsthas_keyR¢trfileR*R¡R´RµR¶R·R°R²R¸R0R«R¹R»R!R RºR ( RXtctypetpdicttvaluestlengthRÀRÁRÂRÃRÄR£R¤R$((s..\modules\mysqldoclib.pytdo_POSTñs.! S  + cGst|jj||ƒdS(N(R RºR (RXtmessagetargs((s..\modules\mysqldoclib.pyR st-cCs3t|jjd|jt|ƒt|ƒfƒdS(Ns "%s" %s %s(R RºR t requestlineRh(RXtcodetsize((s..\modules\mysqldoclib.pyt log_requestscGst|jj||ƒdS(N(R RºR (RXR×RØ((s..\modules\mysqldoclib.pyRs(RIRJRÉRÖR RÝR(((s..\modules\mysqldoclib.pyR¬ƒs  l & iiRBcCsÚ|ay¢yttƒ}zYt||ftƒ}||_||_t|d|ƒ|rc|jƒn|jƒWd|j ƒXWn't k r¦}t d|ƒ|‚nXWn+t k rÕt|dƒ|j j ƒnXdS(NsStarted HTTP server on port %d.s;An error occurred while opening the database connection. %rs7Keyboard interrupt received, shutting down HTTP server.(RR˜RR¬R R"R tsett serve_foreverR R!RtKeyboardInterrupttsocket(tportR tdatadirt ready_eventtbindR"RºR$((s..\modules\mysqldoclib.pyt serve_docs s&      cCs dGHdS(NsMySQL Document Library Standalone Application - mysqldoclib.py Usage: wbdocs.py -h -pPort -v [build-lib | rebuild-lib | build-webui | rebuild-webui | serve-docs] This applications serves and maintains a documentation library for MySQL products. build-lib | rebuild-lib These commands create the documentation library repository. build-webui | rebuild-webui These commands rebuild the webui repository that is used to server the web pages. serve-docs This argument launches a web server to server the documentation library((((s..\modules\mysqldoclib.pytusage=s c Cs­y/tjtjdddddgƒ\}}Wn9tjk rj}dGt|ƒGHtƒtjdƒnXt}d}d }d }x¬|D]¤\}} |d kr«t}qŠ|dkrËtƒtjƒqŠ|dkr| j ƒròt | ƒ}q.ts.t dƒ‚qŠ|dkr| }qŠtsŠt dƒ‚qŠW|r¢|ddkr_t |||dƒn|ddkrt ||ƒq©|ddkr©t||ƒq©ntƒdS(Nishp:d:vthelpsport=sdb=s!Invalid option passed to module. iiRBs-vs-hs--helps-ps--ports$The specified port must be a number.s-ds--dbsUnhandled option.is build-libs rebuild-libs build-webuis rebuild-webuis serve-docs(s-hs--help(s-ps--port(s-ds--db(s build-libs rebuild-lib(s build-webuis rebuild-webui(tgetoptRtargvt GetoptErrorRhRçtexitR3R5tisdigitR¢tAssertionErrorRŽR—Ræ( RêtoptsRØR$R Râtdb_namet timestamptota((s..\modules\mysqldoclib.pytmainLs>/        t__main__((7RéRtos.pathRt pysqlite2RRt ImportErrorR(R9t threadingRVttimeRoRËtBaseHTTPServerRRRRRRRiRRR R RRRR%R&R.R2R7R>R?RFRGRHtThreadRORdRŒRŽR—R˜R«R¬tNoneRæRçRôRIRê(((s..\modules\mysqldoclib.pytsV    0       :        ( %  6  ]  '