assorted-commits Mailing List for Assorted projects (Page 8)
Brought to you by:
yangzhang
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(9) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(86) |
Feb
(265) |
Mar
(96) |
Apr
(47) |
May
(136) |
Jun
(28) |
Jul
(57) |
Aug
(42) |
Sep
(20) |
Oct
(67) |
Nov
(37) |
Dec
(34) |
2009 |
Jan
(39) |
Feb
(85) |
Mar
(96) |
Apr
(24) |
May
(82) |
Jun
(13) |
Jul
(10) |
Aug
(8) |
Sep
(2) |
Oct
(20) |
Nov
(31) |
Dec
(17) |
2010 |
Jan
(16) |
Feb
(11) |
Mar
(17) |
Apr
(53) |
May
(31) |
Jun
(13) |
Jul
(3) |
Aug
(6) |
Sep
(11) |
Oct
(4) |
Nov
(17) |
Dec
(17) |
2011 |
Jan
(3) |
Feb
(19) |
Mar
(5) |
Apr
(17) |
May
(3) |
Jun
(4) |
Jul
(14) |
Aug
(3) |
Sep
(2) |
Oct
(1) |
Nov
(3) |
Dec
(2) |
2012 |
Jan
(3) |
Feb
(7) |
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
(4) |
Aug
(5) |
Sep
(2) |
Oct
(3) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(9) |
Apr
(5) |
May
|
Jun
(2) |
Jul
(1) |
Aug
(10) |
Sep
(1) |
Oct
(2) |
Nov
|
Dec
|
2014 |
Jan
(1) |
Feb
(3) |
Mar
(3) |
Apr
(1) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2016 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(5) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <yan...@us...> - 2010-12-06 08:13:20
|
Revision: 1727 http://assorted.svn.sourceforge.net/assorted/?rev=1727&view=rev Author: yangzhang Date: 2010-12-06 08:13:13 +0000 (Mon, 06 Dec 2010) Log Message: ----------- Added unimpaired.vim Added Paths: ----------- configs/trunk/src/vim/doc/unimpaired.txt configs/trunk/src/vim/plugin/unimpaired.vim Added: configs/trunk/src/vim/doc/unimpaired.txt =================================================================== --- configs/trunk/src/vim/doc/unimpaired.txt (rev 0) +++ configs/trunk/src/vim/doc/unimpaired.txt 2010-12-06 08:13:13 UTC (rev 1727) @@ -0,0 +1,101 @@ +*unimpaired.txt* Pairs of handy bracket mappings + +Author: Tim Pope <vim...@tp...> *unimpaired-author* +License: Same terms as Vim itself (see |license|) + +This plugin is only available if 'compatible' is not set. + +INTRODUCTION *unimpaired* + +This plugin provides several pairs of bracket maps. + +NEXT AND PREVIOUS *unimpaired-next* + +The following maps all correspond to normal mode commands. If a count is +given, it becomes an argument to the command. A mnemonic for the "a" commands +is "args" and for the "q" commands is "quickfix". + +*[a* |:previous| +*]a* |:next| +*[A* |:first| +*]A* |:last| +*[b* |:bprevious| +*]b* |:bnext| +*[B* |:bfirst| +*]B* |:blast| +*[l* |:lprevious| +*]l* |:lnext| +*[L* |:lfirst| +*]L* |:llast| +*[q* |:cprevious| +*]q* |:cnext| +*[Q* |:cfirst| +*]Q* |:clast| + + *[o* +[o Go to the file preceding the current one + alphabetically in the current file's directory. + + *]o* +]o Go to the file succeeding the current one + alphabetically in the current file's directory. + +LINE OPERATIONS *unimpaired-lines* + + *[<Space>* +[<Space> Add [count] blank lines above the cursor. + + *]<Space>* +]<Space> Add [count] blank lines below the cursor. + + *[e* *v_[e* +[e Exchange the current line with [count] lines above it. + + *]e* *v_]e* +]e Exchange the current line with [count] lines below it. + +ENCODING AND DECODING *unimpaired-encoding* + +Each of these operations has a map that takes a motion, a map that +targets [count] lines, and a visual mode map. The linewise variant integrates +with repeat.vim. + +Mnenomic: encoding always comes before decoding; "[" always comes before "]". + + *[x* *[xx* *v_[x* +[x{motion} XML encode. +[xx <foo bar="baz"> => <foo bar="baz"> +{Visual}[x + + *]x* *]xx* *v_]x* +]x{motion} XML decode. HTML entities are handled as well. +]xx +{Visual}]x + + *[u* *[uu* *v_[u* +[u{motion} URL encode. +[uu foo bar => foo%20bar +{Visual}[u + + *]u* *]uu* *v_]u* +]u{motion} URL decode. +]uu +{Visual}]u + + *[y* *[yy* *v_[y* +[y{motion} C String encode. Backslash escape control +[yy characters, quotation marks, and backslashes. +{Visual}[y + + *]y* *]yy* *v_]y* +]y{motion} C String decode. +]yy +{Visual}]y + +TODO *unimpaired-todo* + +Descend into and ascend from directories with |[o| and |]o|. + +Avoid munging null characters when encoding and decoding. + + vim:tw=78:et:ft=help:norl: Added: configs/trunk/src/vim/plugin/unimpaired.vim =================================================================== --- configs/trunk/src/vim/plugin/unimpaired.vim (rev 0) +++ configs/trunk/src/vim/plugin/unimpaired.vim 2010-12-06 08:13:13 UTC (rev 1727) @@ -0,0 +1,260 @@ +" unimpaired.vim - Pairs of handy bracket mappings +" Maintainer: Tim Pope <vim...@tp...> +" Version: 1.1 + +if exists("g:loaded_unimpaired") || &cp || v:version < 700 + finish +endif +let g:loaded_unimpaired = 1 + +let s:cpo_save = &cpo +set cpo&vim + +" Next and previous {{{1 + +function! s:MapNextFamily(map,cmd) + let map = '<Plug>unimpaired'.toupper(a:map) + let end = ' ".(v:count ? v:count : "")<CR>' + execute 'nmap <silent> '.map.'Previous :<C-U>exe "'.a:cmd.'previous'.end + execute 'nmap <silent> '.map.'Next :<C-U>exe "'.a:cmd.'next'.end + execute 'nmap <silent> '.map.'First :<C-U>exe "'.a:cmd.'first'.end + execute 'nmap <silent> '.map.'Last :<C-U>exe "'.a:cmd.'last'.end + execute 'nmap <silent> ['. a:map .' '.map.'Previous' + execute 'nmap <silent> ]'. a:map .' '.map.'Next' + execute 'nmap <silent> ['.toupper(a:map).' '.map.'First' + execute 'nmap <silent> ]'.toupper(a:map).' '.map.'Last' +endfunction + +call s:MapNextFamily('a','') +call s:MapNextFamily('b','b') +call s:MapNextFamily('l','l') +call s:MapNextFamily('q','c') + +function! s:FileByOffset(num) + let original = expand("%") + if a:num == 0 + return original + endif + let dir = fnamemodify(original,':h') + if dir == '.' + let dir = '' + elseif dir != '' + let dir .= '/' + endif + let files = split(glob(dir.".*"),"\n") + let files += split(glob(dir."*"),"\n") + call filter(files,'v:val !=# "." && v:val !=# ".."') + call filter(files,'v:val[-4:-1] !=# ".swp" && v:val[-1:-1] !=# "~"') + if a:num < 0 + call reverse(sort(filter(files,'v:val < original'))) + else + call sort(filter(files,'v:val > original')) + end + let num = a:num < 0 ? -a:num : a:num + let file = get(files,num-1,get(files,-1,original)) + return file +endfunction + +nnoremap <silent> <Plug>unimpairedONext :<C-U>edit `=<SID>FileByOffset(v:count1)`<CR> +nnoremap <silent> <Plug>unimpairedOPrevious :<C-U>edit `=<SID>FileByOffset(-v:count1)`<CR> + +nmap ]o <Plug>unimpairedONext +nmap [o <Plug>unimpairedOPrevious + +" }}}1 +" Line operations {{{1 + +nnoremap <silent> <Plug>unimpairedBlankUp :<C-U>put!=repeat(nr2char(10),v:count)<Bar>']+1<CR> +nnoremap <silent> <Plug>unimpairedBlankDown :<C-U>put =repeat(nr2char(10),v:count)<Bar>'[-1<CR> + +nmap [<Space> <Plug>unimpairedBlankUp +nmap ]<Space> <Plug>unimpairedBlankDown + +nnoremap <silent> <Plug>unimpairedMoveUp :<C-U>exe 'norm m`'<Bar>exe 'move--'.v:count1<CR>`` +nnoremap <silent> <Plug>unimpairedMoveDown :<C-U>exe 'norm m`'<Bar>exe 'move+'.v:count1<CR>`` +xnoremap <silent> <Plug>unimpairedMoveUp :<C-U>exe 'norm m`'<Bar>exe '''<,''>move--'.v:count1<CR>`` +xnoremap <silent> <Plug>unimpairedMoveDown :<C-U>exe 'norm m`'<Bar>exe '''<,''>move''>+'.v:count1<CR>`` + +nmap [e <Plug>unimpairedMoveUp +nmap ]e <Plug>unimpairedMoveDown +xmap [e <Plug>unimpairedMoveUp +xmap ]e <Plug>unimpairedMoveDown + +" }}}1 +" Encoding and decoding {{{1 + +function! s:StringEncode(str) + let map = {"\n": 'n', "\r": 'r', "\t": 't', "\b": 'b', "\f": '\f', '"': '"', '\': '\'} + return substitute(a:str,"[\001-\033\\\\\"]",'\="\\".get(map,submatch(0),printf("%03o",char2nr(submatch(0))))','g') +endfunction + +function! s:StringDecode(str) + let map = {'n': "\n", 'r': "\r", 't': "\t", 'b': "\b", 'f': "\f", 'e': "\e", 'a': "\001", 'v': "\013", '"': '"', '\': '\', "'": "'"} + let str = a:str + if str =~ '^\s*".\{-\}\\\@<!\%(\\\\\)*"\s*\n\=$' + let str = substitute(substitute(str,'^\s*\zs"','',''),'"\ze\s*\n\=$','','') + endif + let str = substitute(str,'\\n\%(\n$\)\=','\n','g') + return substitute(str,'\\\(\o\{1,3\}\|x\x\{1,2\}\|u\x\{1,4\}\|.\)','\=get(map,submatch(1),nr2char("0".substitute(submatch(1),"^[Uu]","x","")))','g') +endfunction + +function! s:UrlEncode(str) + return substitute(a:str,'[^A-Za-z0-9_.~-]','\="%".printf("%02X",char2nr(submatch(0)))','g') +endfunction + +function! s:UrlDecode(str) + let str = substitute(substitute(substitute(a:str,'%0[Aa]\n$','%0A',''),'%0[Aa]','\n','g'),'+',' ','g') + return substitute(str,'%\(\x\x\)','\=nr2char("0x".submatch(1))','g') +endfunction + +" HTML entities {{{2 + +let g:unimpaired_html_entities = { + \ 'nbsp': 160, 'iexcl': 161, 'cent': 162, 'pound': 163, + \ 'curren': 164, 'yen': 165, 'brvbar': 166, 'sect': 167, + \ 'uml': 168, 'copy': 169, 'ordf': 170, 'laquo': 171, + \ 'not': 172, 'shy': 173, 'reg': 174, 'macr': 175, + \ 'deg': 176, 'plusmn': 177, 'sup2': 178, 'sup3': 179, + \ 'acute': 180, 'micro': 181, 'para': 182, 'middot': 183, + \ 'cedil': 184, 'sup1': 185, 'ordm': 186, 'raquo': 187, + \ 'frac14': 188, 'frac12': 189, 'frac34': 190, 'iquest': 191, + \ 'Agrave': 192, 'Aacute': 193, 'Acirc': 194, 'Atilde': 195, + \ 'Auml': 196, 'Aring': 197, 'AElig': 198, 'Ccedil': 199, + \ 'Egrave': 200, 'Eacute': 201, 'Ecirc': 202, 'Euml': 203, + \ 'Igrave': 204, 'Iacute': 205, 'Icirc': 206, 'Iuml': 207, + \ 'ETH': 208, 'Ntilde': 209, 'Ograve': 210, 'Oacute': 211, + \ 'Ocirc': 212, 'Otilde': 213, 'Ouml': 214, 'times': 215, + \ 'Oslash': 216, 'Ugrave': 217, 'Uacute': 218, 'Ucirc': 219, + \ 'Uuml': 220, 'Yacute': 221, 'THORN': 222, 'szlig': 223, + \ 'agrave': 224, 'aacute': 225, 'acirc': 226, 'atilde': 227, + \ 'auml': 228, 'aring': 229, 'aelig': 230, 'ccedil': 231, + \ 'egrave': 232, 'eacute': 233, 'ecirc': 234, 'euml': 235, + \ 'igrave': 236, 'iacute': 237, 'icirc': 238, 'iuml': 239, + \ 'eth': 240, 'ntilde': 241, 'ograve': 242, 'oacute': 243, + \ 'ocirc': 244, 'otilde': 245, 'ouml': 246, 'divide': 247, + \ 'oslash': 248, 'ugrave': 249, 'uacute': 250, 'ucirc': 251, + \ 'uuml': 252, 'yacute': 253, 'thorn': 254, 'yuml': 255, + \ 'OElig': 338, 'oelig': 339, 'Scaron': 352, 'scaron': 353, + \ 'Yuml': 376, 'circ': 710, 'tilde': 732, 'ensp': 8194, + \ 'emsp': 8195, 'thinsp': 8201, 'zwnj': 8204, 'zwj': 8205, + \ 'lrm': 8206, 'rlm': 8207, 'ndash': 8211, 'mdash': 8212, + \ 'lsquo': 8216, 'rsquo': 8217, 'sbquo': 8218, 'ldquo': 8220, + \ 'rdquo': 8221, 'bdquo': 8222, 'dagger': 8224, 'Dagger': 8225, + \ 'permil': 8240, 'lsaquo': 8249, 'rsaquo': 8250, 'euro': 8364, + \ 'fnof': 402, 'Alpha': 913, 'Beta': 914, 'Gamma': 915, + \ 'Delta': 916, 'Epsilon': 917, 'Zeta': 918, 'Eta': 919, + \ 'Theta': 920, 'Iota': 921, 'Kappa': 922, 'Lambda': 923, + \ 'Mu': 924, 'Nu': 925, 'Xi': 926, 'Omicron': 927, + \ 'Pi': 928, 'Rho': 929, 'Sigma': 931, 'Tau': 932, + \ 'Upsilon': 933, 'Phi': 934, 'Chi': 935, 'Psi': 936, + \ 'Omega': 937, 'alpha': 945, 'beta': 946, 'gamma': 947, + \ 'delta': 948, 'epsilon': 949, 'zeta': 950, 'eta': 951, + \ 'theta': 952, 'iota': 953, 'kappa': 954, 'lambda': 955, + \ 'mu': 956, 'nu': 957, 'xi': 958, 'omicron': 959, + \ 'pi': 960, 'rho': 961, 'sigmaf': 962, 'sigma': 963, + \ 'tau': 964, 'upsilon': 965, 'phi': 966, 'chi': 967, + \ 'psi': 968, 'omega': 969, 'thetasym': 977, 'upsih': 978, + \ 'piv': 982, 'bull': 8226, 'hellip': 8230, 'prime': 8242, + \ 'Prime': 8243, 'oline': 8254, 'frasl': 8260, 'weierp': 8472, + \ 'image': 8465, 'real': 8476, 'trade': 8482, 'alefsym': 8501, + \ 'larr': 8592, 'uarr': 8593, 'rarr': 8594, 'darr': 8595, + \ 'harr': 8596, 'crarr': 8629, 'lArr': 8656, 'uArr': 8657, + \ 'rArr': 8658, 'dArr': 8659, 'hArr': 8660, 'forall': 8704, + \ 'part': 8706, 'exist': 8707, 'empty': 8709, 'nabla': 8711, + \ 'isin': 8712, 'notin': 8713, 'ni': 8715, 'prod': 8719, + \ 'sum': 8721, 'minus': 8722, 'lowast': 8727, 'radic': 8730, + \ 'prop': 8733, 'infin': 8734, 'ang': 8736, 'and': 8743, + \ 'or': 8744, 'cap': 8745, 'cup': 8746, 'int': 8747, + \ 'there4': 8756, 'sim': 8764, 'cong': 8773, 'asymp': 8776, + \ 'ne': 8800, 'equiv': 8801, 'le': 8804, 'ge': 8805, + \ 'sub': 8834, 'sup': 8835, 'nsub': 8836, 'sube': 8838, + \ 'supe': 8839, 'oplus': 8853, 'otimes': 8855, 'perp': 8869, + \ 'sdot': 8901, 'lceil': 8968, 'rceil': 8969, 'lfloor': 8970, + \ 'rfloor': 8971, 'lang': 9001, 'rang': 9002, 'loz': 9674, + \ 'spades': 9824, 'clubs': 9827, 'hearts': 9829, 'diams': 9830, + \ 'apos': 39} + +" }}}2 + +function! s:XmlEncode(str) + let str = a:str + let str = substitute(str,'&','\&','g') + let str = substitute(str,'<','\<','g') + let str = substitute(str,'>','\>','g') + let str = substitute(str,'"','\"','g') + return str +endfunction + +function! s:XmlEntityDecode(str) + let str = substitute(a:str,'\c&#\%(0*38\|x0*26\);','&','g') + let str = substitute(str,'\c&#\(\d\+\);','\=nr2char(submatch(1))','g') + let str = substitute(str,'\c&#\(x\x\+\);','\=nr2char("0".submatch(1))','g') + let str = substitute(str,'\c'',"'",'g') + let str = substitute(str,'\c"','"','g') + let str = substitute(str,'\c>','>','g') + let str = substitute(str,'\c<','<','g') + let str = substitute(str,'\C&\(\%(amp;\)\@!\w*\);','\=nr2char(get(g:unimpaired_html_entities,submatch(1),63))','g') + return substitute(str,'\c&','\&','g') +endfunction + +function! s:XmlDecode(str) + let str = substitute(a:str,'<\%([[:alnum:]-]\+=\%("[^"]*"\|''[^'']*''\)\|.\)\{-\}>','','g') + return s:XmlEntityDecode(str) +endfunction + +function! s:Transform(algorithm,type) + let sel_save = &selection + let cb_save = &clipboard + set selection=inclusive clipboard-=unnamed + let reg_save = @@ + if a:type =~ '^\d\+$' + silent exe 'norm! ^v'.a:type.'$hy' + elseif a:type =~ '^.$' + silent exe "normal! `<" . a:type . "`>y" + elseif a:type == 'line' + silent exe "normal! '[V']y" + elseif a:type == 'block' + silent exe "normal! `[\<C-V>`]y" + else + silent exe "normal! `[v`]y" + endif + let @@ = s:{a:algorithm}(@@) + norm! gvp + let @@ = reg_save + let &selection = sel_save + let &clipboard = cb_save + if a:type =~ '^\d\+$' + silent! call repeat#set("\<Plug>unimpairedLine".a:algorithm,a:type) + endif +endfunction + +function! s:TransformOpfunc(type) + return s:Transform(s:encode_algorithm, a:type) +endfunction + +function! s:TransformSetup(algorithm) + let s:encode_algorithm = a:algorithm + let &opfunc = matchstr(expand('<sfile>'), '<SNR>\d\+_').'TransformOpfunc' +endfunction + +function! s:MapTransform(algorithm, key) + exe 'nnoremap <silent> <Plug>unimpaired' .a:algorithm.' :<C-U>call <SID>TransformSetup("'.a:algorithm.'")<CR>g@' + exe 'xnoremap <silent> <Plug>unimpaired' .a:algorithm.' :<C-U>call <SID>Transform("'.a:algorithm.'",visualmode())<CR>' + exe 'nnoremap <silent> <Plug>unimpairedLine'.a:algorithm.' :<C-U>call <SID>Transform("'.a:algorithm.'",v:count1)<CR>' + exe 'nmap '.a:key.' <Plug>unimpaired'.a:algorithm + exe 'xmap '.a:key.' <Plug>unimpaired'.a:algorithm + exe 'nmap '.a:key.a:key[strlen(a:key)-1].' <Plug>unimpairedLine'.a:algorithm +endfunction + +call s:MapTransform('StringEncode','[y') +call s:MapTransform('StringDecode',']y') +call s:MapTransform('UrlEncode','[u') +call s:MapTransform('UrlDecode',']u') +call s:MapTransform('XmlEncode','[x') +call s:MapTransform('XmlDecode',']x') + +" }}}1 + +let &cpo = s:cpo_save + +" vim:set ft=vim ts=8 sw=2 sts=2: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-12-04 19:14:09
|
Revision: 1726 http://assorted.svn.sourceforge.net/assorted/?rev=1726&view=rev Author: yangzhang Date: 2010-12-04 19:14:03 +0000 (Sat, 04 Dec 2010) Log Message: ----------- Simplified sync-bookmarks.bash Modified Paths: -------------- configs/trunk/src/cron/sync-bookmarks.bash Modified: configs/trunk/src/cron/sync-bookmarks.bash =================================================================== --- configs/trunk/src/cron/sync-bookmarks.bash 2010-12-02 20:25:45 UTC (rev 1725) +++ configs/trunk/src/cron/sync-bookmarks.bash 2010-12-04 19:14:03 UTC (rev 1726) @@ -1,3 +1,3 @@ #!/usr/bin/env bash -PS1='$' . ~/.bashrc && . common.bash || exit 1 +. ~/.bashrc || exit 1 exec gbookmark2delicious &>> /tmp/gbookmark2delicious.log This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-12-02 20:25:51
|
Revision: 1725 http://assorted.svn.sourceforge.net/assorted/?rev=1725&view=rev Author: yangzhang Date: 2010-12-02 20:25:45 +0000 (Thu, 02 Dec 2010) Log Message: ----------- Tweak sync-bookmarks syntax Modified Paths: -------------- configs/trunk/src/cron/sync-bookmarks.bash Modified: configs/trunk/src/cron/sync-bookmarks.bash =================================================================== --- configs/trunk/src/cron/sync-bookmarks.bash 2010-11-29 23:59:56 UTC (rev 1724) +++ configs/trunk/src/cron/sync-bookmarks.bash 2010-12-02 20:25:45 UTC (rev 1725) @@ -1,3 +1,3 @@ #!/usr/bin/env bash PS1='$' . ~/.bashrc && . common.bash || exit 1 -exec gbookmark2delicious >> /tmp/gbookmark2delicious.log 2>&1 +exec gbookmark2delicious &>> /tmp/gbookmark2delicious.log This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-30 00:00:02
|
Revision: 1724 http://assorted.svn.sourceforge.net/assorted/?rev=1724&view=rev Author: yangzhang Date: 2010-11-29 23:59:56 +0000 (Mon, 29 Nov 2010) Log Message: ----------- Stubbornly retry if no drop-downs on united Modified Paths: -------------- sandbox/trunk/src/one-off-scripts/flight-search/flights.py Modified: sandbox/trunk/src/one-off-scripts/flight-search/flights.py =================================================================== --- sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-29 23:59:34 UTC (rev 1723) +++ sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-29 23:59:56 UTC (rev 1724) @@ -90,11 +90,15 @@ @retry_if_timeout def united(org, dst): wd.get('http://united.com') + trial = 0 while (fullcity(org) not in getid('shop_from0_temp').get_value() or fullcity(dst) not in getid('shop_to0_temp').get_value()): getid('shop_from0_temp').click().delay().send_keys(org).delay(5).tab().delay() getid('shop_to0_temp').click().delay().send_keys(dst).delay(5).tab().delay() getid('shop_from0_temp').click().delay() + trial += 1 + if trial > 3: + raise timeout_exception() #getid('fromnearby1').click() #getid('tonearby1').click() getid('wayOne').click().delay() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-29 23:59:40
|
Revision: 1723 http://assorted.svn.sourceforge.net/assorted/?rev=1723&view=rev Author: yangzhang Date: 2010-11-29 23:59:34 +0000 (Mon, 29 Nov 2010) Log Message: ----------- Manual nearby airport selection Modified Paths: -------------- sandbox/trunk/src/one-off-scripts/flight-search/flights.py Modified: sandbox/trunk/src/one-off-scripts/flight-search/flights.py =================================================================== --- sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-24 23:25:44 UTC (rev 1722) +++ sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-29 23:59:34 UTC (rev 1723) @@ -81,7 +81,11 @@ return getattr(self.elt, attr) def fullcity(tla): - return dict(ewr = 'Newark', sfo = 'San Francisco', phl = 'Philadelphia')[tla] + return dict(ewr = 'Newark', + sfo = 'San Francisco', + phl = 'Philadelphia', + oak = 'Oakland', + sjc = 'San Jose')[tla.lower()] @retry_if_timeout def united(org, dst): @@ -173,7 +177,9 @@ logging.basicConfig() newres = {} - defaultports = [('phl','sfo'),('ewr','sfo')] + orgs = 'ewr phl'.split() + dsts = 'oak sfo sjc'.split() + defaultports = [(org, dst) for org in orgs for dst in dsts] airline2orgdsts = dict(virginamerica = [('jfk','sfo')]) airlines = 'aa united bing virginamerica'.split() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-24 23:25:50
|
Revision: 1722 http://assorted.svn.sourceforge.net/assorted/?rev=1722&view=rev Author: yangzhang Date: 2010-11-24 23:25:44 +0000 (Wed, 24 Nov 2010) Log Message: ----------- Added swig demo Added Paths: ----------- sandbox/trunk/src/misc/swig/ sandbox/trunk/src/misc/swig/Makefile sandbox/trunk/src/misc/swig/pyre2.h sandbox/trunk/src/misc/swig/pyre2.i Added: sandbox/trunk/src/misc/swig/Makefile =================================================================== --- sandbox/trunk/src/misc/swig/Makefile (rev 0) +++ sandbox/trunk/src/misc/swig/Makefile 2010-11-24 23:25:44 UTC (rev 1722) @@ -0,0 +1,13 @@ +all: _pyre2.so + +_pyre2.so: pyre2.i + swig -python -c++ pyre2.i + g++ -fPIC -c -I /usr/include/python2.6 pyre2_wrap.cxx + g++ -shared pyre2_wrap.o -o _pyre2.so + +test: all + python -c 'import pyre2; print pyre2.g' + +.PHONY: clean +clean: + rm -f _pyre2.so pyre2.py pyre2_wrap.* *.pyc Added: sandbox/trunk/src/misc/swig/pyre2.h =================================================================== --- sandbox/trunk/src/misc/swig/pyre2.h (rev 0) +++ sandbox/trunk/src/misc/swig/pyre2.h 2010-11-24 23:25:44 UTC (rev 1722) @@ -0,0 +1,9 @@ +class C { + int x; + int y; + public: + int z; + int foo() { return z; } +}; +extern const int g = 0; +int bar() { return g; } Added: sandbox/trunk/src/misc/swig/pyre2.i =================================================================== --- sandbox/trunk/src/misc/swig/pyre2.i (rev 0) +++ sandbox/trunk/src/misc/swig/pyre2.i 2010-11-24 23:25:44 UTC (rev 1722) @@ -0,0 +1,5 @@ +%module pyre2 +%{ +#include "pyre2.h" +%} +%include "pyre2.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-24 04:44:13
|
Revision: 1721 http://assorted.svn.sourceforge.net/assorted/?rev=1721&view=rev Author: yangzhang Date: 2010-11-24 04:44:07 +0000 (Wed, 24 Nov 2010) Log Message: ----------- Disabled nearby airport search Modified Paths: -------------- sandbox/trunk/src/one-off-scripts/flight-search/flights.py Modified: sandbox/trunk/src/one-off-scripts/flight-search/flights.py =================================================================== --- sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-18 01:31:52 UTC (rev 1720) +++ sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-24 04:44:07 UTC (rev 1721) @@ -91,8 +91,8 @@ getid('shop_from0_temp').click().delay().send_keys(org).delay(5).tab().delay() getid('shop_to0_temp').click().delay().send_keys(dst).delay(5).tab().delay() getid('shop_from0_temp').click().delay() - getid('fromnearby1').click() - getid('tonearby1').click() + #getid('fromnearby1').click() + #getid('tonearby1').click() getid('wayOne').click().delay() getid('shop_depart0').clear().send_keys('12/31/10').delay().tab().delay() getid('SearchByPRICE').click() @@ -104,8 +104,8 @@ wd.get('http://www.aa.com/reservation/oneWaySearchAccess.do') getid('flightSearchForm.originAirport').clear().send_keys(org) getid('flightSearchForm.destinationAirport').clear().send_keys(dst) - getid('flightSearchForm.originAlternateAirportDistance').option(60) - getid('flightSearchForm.destinationAlternateAirportDistance').option(60) + #getid('flightSearchForm.originAlternateAirportDistance').option(60) + #getid('flightSearchForm.destinationAlternateAirportDistance').option(60) getid('flightSearchForm.flightParams.flightDateParams.travelMonth').option(12) getid('flightSearchForm.flightParams.flightDateParams.travelDay').option(31) getid('flightSearchForm.flightParams.flightDateParams.searchTime').option(120001) @@ -143,8 +143,8 @@ xpath('//span[@class="ac_portName"]/..', False).click().delay(1) getid('dest1Text').click().clear().send_keys(dst).delay(5).tab() xpath('//span[@class="ac_portName"]/..', False).click().delay(1) - getid('no').click() - getid('ne').click() + #getid('no').click() + #getid('ne').click() getid('leave1').clear().send_keys('12/31/10').delay() getid('submitBtn').click() return toprc(xpath('//table[@class="resultsTable"]//span[@class="price"]')) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-18 01:31:58
|
Revision: 1720 http://assorted.svn.sourceforge.net/assorted/?rev=1720&view=rev Author: yangzhang Date: 2010-11-18 01:31:52 +0000 (Thu, 18 Nov 2010) Log Message: ----------- CSV results plotter for flight-search Added Paths: ----------- sandbox/trunk/src/one-off-scripts/flight-search/plot.py Added: sandbox/trunk/src/one-off-scripts/flight-search/plot.py =================================================================== --- sandbox/trunk/src/one-off-scripts/flight-search/plot.py (rev 0) +++ sandbox/trunk/src/one-off-scripts/flight-search/plot.py 2010-11-18 01:31:52 UTC (rev 1720) @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +import csv, re, sys + +ts = None +nums = re.compile(r'\d\d\d') +minx = float('inf') +w = csv.writer(sys.stdout) +for line in sys.stdin: + if line.startswith('From '): + if minx < float('inf'): + w.writerow((ts, minx)) + minx = float('inf') + ts = line.split(' ',1)[1].strip() + else: + minx = min(minx, int(nums.search(line).group())) Property changes on: sandbox/trunk/src/one-off-scripts/flight-search/plot.py ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-16 23:22:14
|
Revision: 1719 http://assorted.svn.sourceforge.net/assorted/?rev=1719&view=rev Author: yangzhang Date: 2010-11-16 23:22:08 +0000 (Tue, 16 Nov 2010) Log Message: ----------- Tweaked for new AA site Modified Paths: -------------- sandbox/trunk/src/one-off-scripts/flight-search/flights.py Modified: sandbox/trunk/src/one-off-scripts/flight-search/flights.py =================================================================== --- sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-12 03:47:54 UTC (rev 1718) +++ sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-16 23:22:08 UTC (rev 1719) @@ -101,16 +101,16 @@ @retry_if_timeout def aa(org, dst): - wd.get('http://aa.com') - getid('flightSearchForm.tripType.oneWay').click() - getid('reservationFlightSearchForm.originAirport').clear().send_keys(org) - getid('reservationFlightSearchForm.destinationAirport').clear().send_keys(dst) + wd.get('http://www.aa.com/reservation/oneWaySearchAccess.do') + getid('flightSearchForm.originAirport').clear().send_keys(org) + getid('flightSearchForm.destinationAirport').clear().send_keys(dst) getid('flightSearchForm.originAlternateAirportDistance').option(60) getid('flightSearchForm.destinationAlternateAirportDistance').option(60) - getid('reservationFlightSearchForm.flightParams.flightDateParams.travelMonth').option(12) - getid('reservationFlightSearchForm.flightParams.flightDateParams.travelDay').option(31) - getid('reservationFlightSearchForm.flightParams.flightDateParams.searchTime').option(120001) - getid('reservationFlightSearchForm').submit() + getid('flightSearchForm.flightParams.flightDateParams.travelMonth').option(12) + getid('flightSearchForm.flightParams.flightDateParams.travelDay').option(31) + getid('flightSearchForm.flightParams.flightDateParams.searchTime').option(120001) + getid('flightSearchForm.carrierAll').click() + getid('flightSearchForm').submit() val = toprc(xpath('//span[@class="highlightSubHeader"]/a/span')) minday = min((toprc(prc), day.get_text()) for prc, day in This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-12 03:48:00
|
Revision: 1718 http://assorted.svn.sourceforge.net/assorted/?rev=1718&view=rev Author: yangzhang Date: 2010-11-12 03:47:54 +0000 (Fri, 12 Nov 2010) Log Message: ----------- git unstage Modified Paths: -------------- configs/trunk/src/gitconfig Modified: configs/trunk/src/gitconfig =================================================================== --- configs/trunk/src/gitconfig 2010-11-08 22:09:05 UTC (rev 1717) +++ configs/trunk/src/gitconfig 2010-11-12 03:47:54 UTC (rev 1718) @@ -15,6 +15,7 @@ k = log --decorate --oneline --graph # colorful 1-line log summary slog = log --pretty=format:'%Creset%C(red bold)[%ad] %C(blue bold)%h %Creset%C(magenta bold)%d %Creset%s %C(green bold)(%an)%Creset' --abbrev-commit --date=short + unstage = reset HEAD -- [core] excludesfile = /home/yang/.gitignore [user] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-08 22:09:11
|
Revision: 1717 http://assorted.svn.sourceforge.net/assorted/?rev=1717&view=rev Author: yangzhang Date: 2010-11-08 22:09:05 +0000 (Mon, 08 Nov 2010) Log Message: ----------- Changed to $NOKEYCHAIN Modified Paths: -------------- shell-tools/trunk/src/bash-commons/bashrc.bash Modified: shell-tools/trunk/src/bash-commons/bashrc.bash =================================================================== --- shell-tools/trunk/src/bash-commons/bashrc.bash 2010-11-08 22:07:06 UTC (rev 1716) +++ shell-tools/trunk/src/bash-commons/bashrc.bash 2010-11-08 22:09:05 UTC (rev 1717) @@ -867,7 +867,7 @@ then keyfile=id_dsa else keyfile= fi -if have keychain && [[ $keyfile && ${USE_KEYCHAIN:-} ]] +if have keychain && [[ $keyfile && ! ${NOKEYCHAIN:-} ]] then eval `keychain --eval --nogui $keychain_flags $keyfile 2> /dev/null` fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-08 22:07:15
|
Revision: 1716 http://assorted.svn.sourceforge.net/assorted/?rev=1716&view=rev Author: yangzhang Date: 2010-11-08 22:07:06 +0000 (Mon, 08 Nov 2010) Log Message: ----------- Added $USE_KEYCHAIN Modified Paths: -------------- shell-tools/trunk/src/bash-commons/bashrc.bash Modified: shell-tools/trunk/src/bash-commons/bashrc.bash =================================================================== --- shell-tools/trunk/src/bash-commons/bashrc.bash 2010-11-05 22:28:59 UTC (rev 1715) +++ shell-tools/trunk/src/bash-commons/bashrc.bash 2010-11-08 22:07:06 UTC (rev 1716) @@ -867,7 +867,7 @@ then keyfile=id_dsa else keyfile= fi -if have keychain && [[ $keyfile ]] +if have keychain && [[ $keyfile && ${USE_KEYCHAIN:-} ]] then eval `keychain --eval --nogui $keychain_flags $keyfile 2> /dev/null` fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-05 22:29:06
|
Revision: 1715 http://assorted.svn.sourceforge.net/assorted/?rev=1715&view=rev Author: yangzhang Date: 2010-11-05 22:28:59 +0000 (Fri, 05 Nov 2010) Log Message: ----------- Refactored out scrape(), slowed down United Modified Paths: -------------- sandbox/trunk/src/one-off-scripts/flight-search/flights.py Modified: sandbox/trunk/src/one-off-scripts/flight-search/flights.py =================================================================== --- sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-05 18:04:35 UTC (rev 1714) +++ sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-05 22:28:59 UTC (rev 1715) @@ -72,6 +72,11 @@ def option(self, val): self.elt.find_element_by_xpath('//option[@value="%s"]' % val).set_selected() return self + def slow_keys(self, keys): + for k in keys: + self.send_keys(k) + time.sleep(.1) + return self def __getattr__(self, attr): return getattr(self.elt, attr) @@ -81,16 +86,15 @@ @retry_if_timeout def united(org, dst): wd.get('http://united.com') - while (fullcity(org) not in getid('shop_from0_temp').get_value() and + while (fullcity(org) not in getid('shop_from0_temp').get_value() or fullcity(dst) not in getid('shop_to0_temp').get_value()): - getid('shop_from0_temp').send_keys(org).delay().tab().delay() - getid('shop_to0_temp').click().delay() - getid('shop_to0_temp').send_keys(dst).delay().tab().delay() + getid('shop_from0_temp').click().delay().send_keys(org).delay(5).tab().delay() + getid('shop_to0_temp').click().delay().send_keys(dst).delay(5).tab().delay() getid('shop_from0_temp').click().delay() getid('fromnearby1').click() getid('tonearby1').click() getid('wayOne').click().delay() - getid('shop_depart0').clear().send_keys('12/31/10') + getid('shop_depart0').clear().send_keys('12/31/10').delay().tab().delay() getid('SearchByPRICE').click() getid('sideform').submit() return toprc(xpath('//div[@class="cloudAmt"]')) @@ -164,14 +168,29 @@ try: yield p finally: p.terminate() -def main(): - global wd +def scrape(): + out = StringIO.StringIO() + logging.basicConfig() + newres = {} defaultports = [('phl','sfo'),('ewr','sfo')] airline2orgdsts = dict(virginamerica = [('jfk','sfo')]) airlines = 'aa united bing virginamerica'.split() - airlines = 'united'.split() + for airline in airlines: + for org, dst in airline2orgdsts.get(airline, defaultports): + res = globals()[airline](org, dst) + val = res[0] if type(res) is tuple else res + newres[airline] = val, res + msg = '%s to %s on %s.com: %s' % (org, dst, airline, res) + print msg + print >> out, msg + + return out + +def main(): + global wd + debug = sys.argv[-1] == '-d' cmd = 'sleep 99999999' if debug else 'Xvfb :1 -screen 0 1600x1200x24' with subproc(cmd.split()) as xvfb: @@ -183,19 +202,8 @@ with quitting(WebDriver()) as wd: sys.stdout, sys.stderr = stdout, stderr - out = StringIO.StringIO() - logging.basicConfig() - newres = {} + out = scrape() - for airline in airlines: - for org, dst in airline2orgdsts.get(airline, defaultports): - res = globals()[airline](org, dst) - val = res[0] if type(res) is tuple else res - newres[airline] = val, res - msg = '%s to %s on %s.com: %s' % (org, dst, airline, res) - print msg - print >> out, msg - #with open(os.path.expanduser('~/.flights.pickle')) as f: # oldres = pickle.load(f) @@ -217,4 +225,4 @@ #with open(os.path.expanduser('~/.flights.pickle'), 'w') as f: # pickle.dump(newres, f) -main() +if __name__ == '__main__': main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-05 18:04:41
|
Revision: 1714 http://assorted.svn.sourceforge.net/assorted/?rev=1714&view=rev Author: yangzhang Date: 2010-11-05 18:04:35 +0000 (Fri, 05 Nov 2010) Log Message: ----------- More robust completion; added debug mode Modified Paths: -------------- sandbox/trunk/src/one-off-scripts/flight-search/flights.py Modified: sandbox/trunk/src/one-off-scripts/flight-search/flights.py =================================================================== --- sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-05 05:12:35 UTC (rev 1713) +++ sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-05 18:04:35 UTC (rev 1714) @@ -1,12 +1,14 @@ """ Automatically search a variety of websites for the best flight deals. + +Run with -d to debug, otherwise runs in Xvfb and emails results. """ from selenium.firefox.webdriver import WebDriver from selenium.firefox.webelement import WebElement from selenium.common.exceptions import NoSuchElementException -import cPickle as pickle, cStringIO as StringIO, contextlib, \ - datetime, functools, logging, ludibrio, os, re, smtplib, subprocess, sys, time +import cPickle as pickle, cStringIO as StringIO, contextlib, datetime, \ + functools, logging, ludibrio, os, re, smtplib, subprocess, sys, time from email.mime.text import MIMEText def retry_if_nexist(f): @@ -73,11 +75,18 @@ def __getattr__(self, attr): return getattr(self.elt, attr) +def fullcity(tla): + return dict(ewr = 'Newark', sfo = 'San Francisco', phl = 'Philadelphia')[tla] + @retry_if_timeout def united(org, dst): wd.get('http://united.com') - getid('shop_from0_temp').send_keys(org).delay().tab() - getid('shop_to0_temp').send_keys(dst).delay().tab() + while (fullcity(org) not in getid('shop_from0_temp').get_value() and + fullcity(dst) not in getid('shop_to0_temp').get_value()): + getid('shop_from0_temp').send_keys(org).delay().tab().delay() + getid('shop_to0_temp').click().delay() + getid('shop_to0_temp').send_keys(dst).delay().tab().delay() + getid('shop_from0_temp').click().delay() getid('fromnearby1').click() getid('tonearby1').click() getid('wayOne').click().delay() @@ -161,9 +170,12 @@ defaultports = [('phl','sfo'),('ewr','sfo')] airline2orgdsts = dict(virginamerica = [('jfk','sfo')]) airlines = 'aa united bing virginamerica'.split() + airlines = 'united'.split() - with subproc('Xvfb :1 -screen 0 1600x1200x24'.split()) as xvfb: - os.environ['DISPLAY'] = ':1' + debug = sys.argv[-1] == '-d' + cmd = 'sleep 99999999' if debug else 'Xvfb :1 -screen 0 1600x1200x24' + with subproc(cmd.split()) as xvfb: + if not debug: os.environ['DISPLAY'] = ':1' # this silencing isn't working stdout, stderr = sys.stdout, sys.stderr sys.stdout = open('/dev/null','w') @@ -193,13 +205,14 @@ # if val <= 180: found = True # print >> out, org, dst, airline, res - mail = MIMEText(out.getvalue()) - mail['From'] = 'ya...@zs...' - mail['To'] = 'ya...@gm..., chr...@gm...' - mail['Subject'] = 'Flight alert for %s' % \ - (datetime.datetime.now().strftime('%a %Y-%m-%d %I:%M %p'),) - with contextlib.closing(smtplib.SMTP('localhost')) as smtp: - smtp.sendmail(mail['From'], mail['To'].split(','), mail.as_string()) + if not debug: + mail = MIMEText(out.getvalue()) + mail['From'] = 'ya...@zs...' + mail['To'] = 'ya...@gm..., chr...@gm...' + mail['Subject'] = 'Flight alert for %s' % \ + (datetime.datetime.now().strftime('%a %Y-%m-%d %I:%M %p'),) + with contextlib.closing(smtplib.SMTP('localhost')) as smtp: + smtp.sendmail(mail['From'], mail['To'].split(','), mail.as_string()) #with open(os.path.expanduser('~/.flights.pickle'), 'w') as f: # pickle.dump(newres, f) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-05 05:12:41
|
Revision: 1713 http://assorted.svn.sourceforge.net/assorted/?rev=1713&view=rev Author: yangzhang Date: 2010-11-05 05:12:35 +0000 (Fri, 05 Nov 2010) Log Message: ----------- Added partycat to ssh_config Modified Paths: -------------- configs/trunk/src/ssh/config Modified: configs/trunk/src/ssh/config =================================================================== --- configs/trunk/src/ssh/config 2010-11-05 05:12:22 UTC (rev 1712) +++ configs/trunk/src/ssh/config 2010-11-05 05:12:35 UTC (rev 1713) @@ -5,6 +5,9 @@ # StrictHostKeyChecking no +Host partycat + HostName 172.20.1.4 + # # appficio # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-05 05:12:28
|
Revision: 1712 http://assorted.svn.sourceforge.net/assorted/?rev=1712&view=rev Author: yangzhang Date: 2010-11-05 05:12:22 +0000 (Fri, 05 Nov 2010) Log Message: ----------- Removed autosetuprebase Modified Paths: -------------- configs/trunk/src/gitconfig Modified: configs/trunk/src/gitconfig =================================================================== --- configs/trunk/src/gitconfig 2010-11-05 05:11:59 UTC (rev 1711) +++ configs/trunk/src/gitconfig 2010-11-05 05:12:22 UTC (rev 1712) @@ -15,8 +15,6 @@ k = log --decorate --oneline --graph # colorful 1-line log summary slog = log --pretty=format:'%Creset%C(red bold)[%ad] %C(blue bold)%h %Creset%C(magenta bold)%d %Creset%s %C(green bold)(%an)%Creset' --abbrev-commit --date=short -[branch] - autosetuprebase = always [core] excludesfile = /home/yang/.gitignore [user] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-05 05:12:06
|
Revision: 1711 http://assorted.svn.sourceforge.net/assorted/?rev=1711&view=rev Author: yangzhang Date: 2010-11-05 05:11:59 +0000 (Fri, 05 Nov 2010) Log Message: ----------- .emacs additions Modified Paths: -------------- configs/trunk/src/emacs/yang.el Modified: configs/trunk/src/emacs/yang.el =================================================================== --- configs/trunk/src/emacs/yang.el 2010-11-04 01:45:35 UTC (rev 1710) +++ configs/trunk/src/emacs/yang.el 2010-11-05 05:11:59 UTC (rev 1711) @@ -120,6 +120,14 @@ ;; sunrise-commander (require 'sunrise-commander) +;; midnight mode purges buffers which haven't been displayed in 3 days +(require 'midnight) +(setq midnight-mode 't) + +;; make buffer names unique even if the files have the same names +(require 'uniquify) +(setq uniquify-buffer-name-style 'forward) + ;; fillcode (require 'fillcode) (add-hook 'c-mode-common-hook 'fillcode-mode) @@ -457,6 +465,18 @@ ;; options {{{ +;; save session state when you quit emacs +(desktop-save-mode 1) + +;; start emacs server so that you can use emacsclient to open new files +;; quickly in your one emacs session (which you start after a reboot and +;; keep open until your next reboot) +(server-start) + +;; allow switching between buffers by typing substring of buffer name +;; (there are other alternatives, but iswitchb comes with std emacs) +(iswitchb-mode 1) + ;; TODO make work in XEmacs ;; default to better frame titles (setq frame-title-format This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-04 01:45:41
|
Revision: 1710 http://assorted.svn.sourceforge.net/assorted/?rev=1710&view=rev Author: yangzhang Date: 2010-11-04 01:45:35 +0000 (Thu, 04 Nov 2010) Log Message: ----------- flight-search emails results and is resilient Modified Paths: -------------- sandbox/trunk/src/one-off-scripts/flight-search/flights.py Modified: sandbox/trunk/src/one-off-scripts/flight-search/flights.py =================================================================== --- sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-03 23:34:52 UTC (rev 1709) +++ sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-04 01:45:35 UTC (rev 1710) @@ -5,20 +5,32 @@ from selenium.firefox.webdriver import WebDriver from selenium.firefox.webelement import WebElement from selenium.common.exceptions import NoSuchElementException -import functools, ludibrio, re, time +import cPickle as pickle, cStringIO as StringIO, contextlib, \ + datetime, functools, logging, ludibrio, os, re, smtplib, subprocess, sys, time +from email.mime.text import MIMEText -wd = WebDriver() - def retry_if_nexist(f): @functools.wraps(f) - def wrapper(x, retry = True): + def wrapper(x, retry = True, maxsec = 60): + start = time.time() while 1: try: return f(x) except NoSuchElementException: - if retry: time.sleep(1) - else: return ludibrio.Dummy() + if not retry: return ludibrio.Dummy() + if time.time() - start > maxsec: raise timeout_exception() + time.sleep(1) return wrapper +class timeout_exception(Exception): pass + +def retry_if_timeout(f): + @functools.wraps(f) + def wrapper(org, dst): + while 1: + try: return f(org, dst) + except timeout_exception: time.sleep(1) + return wrapper + @retry_if_nexist def xpath(x): return rich_web_elt(wd.find_element_by_xpath(x)) @retry_if_nexist @@ -61,6 +73,7 @@ def __getattr__(self, attr): return getattr(self.elt, attr) +@retry_if_timeout def united(org, dst): wd.get('http://united.com') getid('shop_from0_temp').send_keys(org).delay().tab() @@ -73,6 +86,7 @@ getid('sideform').submit() return toprc(xpath('//div[@class="cloudAmt"]')) +@retry_if_timeout def aa(org, dst): wd.get('http://aa.com') getid('flightSearchForm.tripType.oneWay').click() @@ -91,7 +105,8 @@ xpaths('//li[@class="tabNotActive"]/a/u'))) return val, minday -def virgin(org, dst): +@retry_if_timeout +def virginamerica(org, dst): wd.get('http://virginamerica.com') getid('owRadio').click() xpath('//select[@name="flightSearch.origin"]/option[@value=%r]' % org.upper()).set_selected() @@ -107,6 +122,7 @@ zip(prcs, xpaths('//*[@class="fsCarouselDate"]'))) return toprc(prcs[3]), minday +@retry_if_timeout def bing(org, dst): wd.get('http://bing.com/travel') getid('labelOW').click() @@ -120,18 +136,72 @@ getid('submitBtn').click() return toprc(xpath('//table[@class="resultsTable"]//span[@class="price"]')) +@retry_if_timeout def farecmp(): pass +@retry_if_timeout def jetblue(): pass +...@co...ntextmanager +def quitting(x): + try: yield x + finally: x.quit() + +...@co...ntextmanager +def subproc(*args, **kwargs): + p = subprocess.Popen(*args, **kwargs) + try: yield p + finally: p.terminate() + def main(): + global wd + defaultports = [('phl','sfo'),('ewr','sfo')] - airline2orgdsts = dict(virgin = [('jfk','sfo')]) - for airline in 'aa united bing virgin'.split(): - for org, dst in airline2orgdsts.get(airline, defaultports): - print org, dst, airline, globals()[airline](org, dst) - wd.quit() + airline2orgdsts = dict(virginamerica = [('jfk','sfo')]) + airlines = 'aa united bing virginamerica'.split() + with subproc('Xvfb :1 -screen 0 1600x1200x24'.split()) as xvfb: + os.environ['DISPLAY'] = ':1' + # this silencing isn't working + stdout, stderr = sys.stdout, sys.stderr + sys.stdout = open('/dev/null','w') + sys.stderr = open('/dev/null','w') + with quitting(WebDriver()) as wd: + sys.stdout, sys.stderr = stdout, stderr + + out = StringIO.StringIO() + logging.basicConfig() + newres = {} + + for airline in airlines: + for org, dst in airline2orgdsts.get(airline, defaultports): + res = globals()[airline](org, dst) + val = res[0] if type(res) is tuple else res + newres[airline] = val, res + msg = '%s to %s on %s.com: %s' % (org, dst, airline, res) + print msg + print >> out, msg + + #with open(os.path.expanduser('~/.flights.pickle')) as f: + # oldres = pickle.load(f) + + #for airline in airlines: + # (newval, newres), (oldval, oldres) = newres[airline], oldres[airline] + # if newval != oldval and newval <= 180: + # if val <= 180: found = True + # print >> out, org, dst, airline, res + + mail = MIMEText(out.getvalue()) + mail['From'] = 'ya...@zs...' + mail['To'] = 'ya...@gm..., chr...@gm...' + mail['Subject'] = 'Flight alert for %s' % \ + (datetime.datetime.now().strftime('%a %Y-%m-%d %I:%M %p'),) + with contextlib.closing(smtplib.SMTP('localhost')) as smtp: + smtp.sendmail(mail['From'], mail['To'].split(','), mail.as_string()) + + #with open(os.path.expanduser('~/.flights.pickle'), 'w') as f: + # pickle.dump(newres, f) + main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-03 23:34:59
|
Revision: 1709 http://assorted.svn.sourceforge.net/assorted/?rev=1709&view=rev Author: yangzhang Date: 2010-11-03 23:34:52 +0000 (Wed, 03 Nov 2010) Log Message: ----------- Refactoring and bug fixes for flight-search Modified Paths: -------------- sandbox/trunk/src/one-off-scripts/flight-search/flights.py Modified: sandbox/trunk/src/one-off-scripts/flight-search/flights.py =================================================================== --- sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-02 01:23:03 UTC (rev 1708) +++ sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-03 23:34:52 UTC (rev 1709) @@ -5,120 +5,133 @@ from selenium.firefox.webdriver import WebDriver from selenium.firefox.webelement import WebElement from selenium.common.exceptions import NoSuchElementException -import time, re +import functools, ludibrio, re, time wd = WebDriver() -def xpath(x): return wd.find_element_by_xpath(x) -def xpaths(x): return wd.find_elements_by_xpath(x) -def getid(x): return wd.find_element_by_id(x) -def name(x): return xpath('//*[@name=%r]' % (x,)) -def option(id, val): - getid(id).find_element_by_xpath('//option[@value="%s"]' % val).set_selected() +def retry_if_nexist(f): + @functools.wraps(f) + def wrapper(x, retry = True): + while 1: + try: return f(x) + except NoSuchElementException: + if retry: time.sleep(1) + else: return ludibrio.Dummy() + return wrapper +@retry_if_nexist +def xpath(x): return rich_web_elt(wd.find_element_by_xpath(x)) +@retry_if_nexist +def xpaths(x): return map(rich_web_elt, wd.find_elements_by_xpath(x)) +@retry_if_nexist +def getid(x): return rich_web_elt(wd.find_element_by_id(x)) +@retry_if_nexist +def name(x): return rich_web_elt(xpath('//*[@name=%r]' % (x,))) + pat = re.compile(r'\d+') def toprc(x): - return pat.search(x.get_text() if type(x) is WebElement else x).group() + return int(pat.search(x.get_text() + if type(x) is rich_web_elt or type(x) is WebElement + else x).group()) +class rich_web_elt(object): + def __init__(self, elt): + self.elt = elt + def clear(self): + self.elt.clear() + return self + def click(self): + self.elt.click() + return self + def send_keys(self, keys): + self.elt.send_keys(keys) + return self + def delay(self, delay = 1): + time.sleep(delay) + return self + def tab(self): + self.elt.send_keys('\t') + return self + def enter(self): + self.elt.send_keys('\n') + return self + def option(self, val): + self.elt.find_element_by_xpath('//option[@value="%s"]' % val).set_selected() + return self + def __getattr__(self, attr): + return getattr(self.elt, attr) + def united(org, dst): wd.get('http://united.com') - getid('shop_from0_temp').send_keys(org) - getid('shop_to0_temp').send_keys(dst) + getid('shop_from0_temp').send_keys(org).delay().tab() + getid('shop_to0_temp').send_keys(dst).delay().tab() getid('fromnearby1').click() getid('tonearby1').click() - getid('wayOne').click() - time.sleep(1) - getid('shop_depart0').clear() - getid('shop_depart0').send_keys('12/31/10') + getid('wayOne').click().delay() + getid('shop_depart0').clear().send_keys('12/31/10') getid('SearchByPRICE').click() getid('sideform').submit() - while 1: - try: return toprc(xpath('//div[@class="cloudAmt"]')) - except NoSuchElementException: time.sleep(1) + return toprc(xpath('//div[@class="cloudAmt"]')) def aa(org, dst): wd.get('http://aa.com') - while 1: - try: getid('flightSearchForm.tripType.oneWay') - except NoSuchElementException: time.sleep(1) - else: break getid('flightSearchForm.tripType.oneWay').click() - getid('reservationFlightSearchForm.originAirport').send_keys(org) - getid('reservationFlightSearchForm.destinationAirport').send_keys(dst) - option('flightSearchForm.originAlternateAirportDistance', 60) - option('flightSearchForm.destinationAlternateAirportDistance', 60) - option('reservationFlightSearchForm.flightParams.flightDateParams.travelMonth', 12) - option('reservationFlightSearchForm.flightParams.flightDateParams.travelDay', 31) - option('reservationFlightSearchForm.flightParams.flightDateParams.searchTime', 120001) + getid('reservationFlightSearchForm.originAirport').clear().send_keys(org) + getid('reservationFlightSearchForm.destinationAirport').clear().send_keys(dst) + getid('flightSearchForm.originAlternateAirportDistance').option(60) + getid('flightSearchForm.destinationAlternateAirportDistance').option(60) + getid('reservationFlightSearchForm.flightParams.flightDateParams.travelMonth').option(12) + getid('reservationFlightSearchForm.flightParams.flightDateParams.travelDay').option(31) + getid('reservationFlightSearchForm.flightParams.flightDateParams.searchTime').option(120001) getid('reservationFlightSearchForm').submit() - while 1: - try: val = toprc(xpath('//span[@class="highlightSubHeader"]/a/span')) - except NoSuchElementException: time.sleep(1) - else: - minday = min((toprc(prc), day.get_text()) - for day, prc in - zip(xpaths('//li[@class="tabNotActive"]/a/u'), - xpaths('//li[@class="tabNotActive"]/a/span'))) - return toprc(val), minday + val = toprc(xpath('//span[@class="highlightSubHeader"]/a/span')) + minday = min((toprc(prc), day.get_text()) + for prc, day in + zip(xpaths('//li[@class="tabNotActive"]/a/span'), + xpaths('//li[@class="tabNotActive"]/a/u'))) + return val, minday def virgin(org, dst): wd.get('http://virginamerica.com') getid('owRadio').click() xpath('//select[@name="flightSearch.origin"]/option[@value=%r]' % org.upper()).set_selected() xpath('//select[@name="flightSearch.destination"]/option[@value=%r]' % dst.upper()).set_selected() - getid('bookFlightCollapseExpandBtn').click() - time.sleep(1) - name ('flightSearch.depDate.MMDDYYYY').clear() - name ('flightSearch.depDate.MMDDYYYY').send_keys('12/31/2010') - time.sleep(1) - try: getid('idclose').click() - except NoSuchElementException: pass - else: time.sleep(1) + getid('bookFlightCollapseExpandBtn').click().delay() + name ('flightSearch.depDate.MMDDYYYY').clear().send_keys('12/31/2010').delay() + # this sometimes doesn't appear + getid('idclose', False).click().delay() getid('SearchFlightBt').click() - while 1: - try: prcs = xpaths('//*[@class="fsCarouselCost"]') - except NoSuchElementException: time.sleep(1) - else: - minday = min((toprc(prc), day.get_text()) - for day, prc in - zip(xpaths('//*[@class="fsCarouselDate"]'), prcs)) - return toprc(prcs[3]), minday + prcs = xpaths('//*[@class="fsCarouselCost"]') + minday = min((toprc(prc), day.get_text()) + for prc, day in + zip(prcs, xpaths('//*[@class="fsCarouselDate"]'))) + return toprc(prcs[3]), minday -def jetblue(): - pass - def bing(org, dst): wd.get('http://bing.com/travel') - getid('labelOW').click() - - getid('orig1Text').send_keys(org) - time.sleep(1) - getid('orig1Text').send_keys('\n') - - getid('dest1Text').send_keys(dst) - time.sleep(1) - getid('orig1Text').send_keys('\n') - + getid('orig1Text').click().clear().send_keys(org).delay(5).tab() + xpath('//span[@class="ac_portName"]/..', False).click().delay(1) + getid('dest1Text').click().clear().send_keys(dst).delay(5).tab() + xpath('//span[@class="ac_portName"]/..', False).click().delay(1) getid('no').click() getid('ne').click() - getid('leave1').clear() - getid('leave1').send_keys('12/31/10') - time.sleep(1) + getid('leave1').clear().send_keys('12/31/10').delay() getid('submitBtn').click() - while 1: - # DEBUG map(toprc, xpaths('//table[@class="resultsTable"]//span[@class="price"]')) - try: return toprc(xpath('//table[@class="resultsTable"]//span[@class="price"]')) - except NoSuchElementException: time.sleep(1) + return toprc(xpath('//table[@class="resultsTable"]//span[@class="price"]')) def farecmp(): pass +def jetblue(): + pass + def main(): - for org, dst in [('phl','sfo'),('ewr','sfo')]: - print 'united %r' % (united(org, dst),) - print 'aa %r' % (aa(org, dst),) - print 'bing %r' % (bing(org, dst),) - print 'virgin %r' % (virgin('jfk', 'sfo'),) + defaultports = [('phl','sfo'),('ewr','sfo')] + airline2orgdsts = dict(virgin = [('jfk','sfo')]) + for airline in 'aa united bing virgin'.split(): + for org, dst in airline2orgdsts.get(airline, defaultports): + print org, dst, airline, globals()[airline](org, dst) + wd.quit() main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-11-02 01:23:10
|
Revision: 1708 http://assorted.svn.sourceforge.net/assorted/?rev=1708&view=rev Author: yangzhang Date: 2010-11-02 01:23:03 +0000 (Tue, 02 Nov 2010) Log Message: ----------- Flight search Added Paths: ----------- sandbox/trunk/src/one-off-scripts/flight-search/ sandbox/trunk/src/one-off-scripts/flight-search/flights.py Added: sandbox/trunk/src/one-off-scripts/flight-search/flights.py =================================================================== --- sandbox/trunk/src/one-off-scripts/flight-search/flights.py (rev 0) +++ sandbox/trunk/src/one-off-scripts/flight-search/flights.py 2010-11-02 01:23:03 UTC (rev 1708) @@ -0,0 +1,124 @@ +""" +Automatically search a variety of websites for the best flight deals. +""" + +from selenium.firefox.webdriver import WebDriver +from selenium.firefox.webelement import WebElement +from selenium.common.exceptions import NoSuchElementException +import time, re + +wd = WebDriver() + +def xpath(x): return wd.find_element_by_xpath(x) +def xpaths(x): return wd.find_elements_by_xpath(x) +def getid(x): return wd.find_element_by_id(x) +def name(x): return xpath('//*[@name=%r]' % (x,)) +def option(id, val): + getid(id).find_element_by_xpath('//option[@value="%s"]' % val).set_selected() + +pat = re.compile(r'\d+') +def toprc(x): + return pat.search(x.get_text() if type(x) is WebElement else x).group() + +def united(org, dst): + wd.get('http://united.com') + getid('shop_from0_temp').send_keys(org) + getid('shop_to0_temp').send_keys(dst) + getid('fromnearby1').click() + getid('tonearby1').click() + getid('wayOne').click() + time.sleep(1) + getid('shop_depart0').clear() + getid('shop_depart0').send_keys('12/31/10') + getid('SearchByPRICE').click() + getid('sideform').submit() + while 1: + try: return toprc(xpath('//div[@class="cloudAmt"]')) + except NoSuchElementException: time.sleep(1) + +def aa(org, dst): + wd.get('http://aa.com') + while 1: + try: getid('flightSearchForm.tripType.oneWay') + except NoSuchElementException: time.sleep(1) + else: break + getid('flightSearchForm.tripType.oneWay').click() + getid('reservationFlightSearchForm.originAirport').send_keys(org) + getid('reservationFlightSearchForm.destinationAirport').send_keys(dst) + option('flightSearchForm.originAlternateAirportDistance', 60) + option('flightSearchForm.destinationAlternateAirportDistance', 60) + option('reservationFlightSearchForm.flightParams.flightDateParams.travelMonth', 12) + option('reservationFlightSearchForm.flightParams.flightDateParams.travelDay', 31) + option('reservationFlightSearchForm.flightParams.flightDateParams.searchTime', 120001) + getid('reservationFlightSearchForm').submit() + while 1: + try: val = toprc(xpath('//span[@class="highlightSubHeader"]/a/span')) + except NoSuchElementException: time.sleep(1) + else: + minday = min((toprc(prc), day.get_text()) + for day, prc in + zip(xpaths('//li[@class="tabNotActive"]/a/u'), + xpaths('//li[@class="tabNotActive"]/a/span'))) + return toprc(val), minday + +def virgin(org, dst): + wd.get('http://virginamerica.com') + getid('owRadio').click() + xpath('//select[@name="flightSearch.origin"]/option[@value=%r]' % org.upper()).set_selected() + xpath('//select[@name="flightSearch.destination"]/option[@value=%r]' % dst.upper()).set_selected() + getid('bookFlightCollapseExpandBtn').click() + time.sleep(1) + name ('flightSearch.depDate.MMDDYYYY').clear() + name ('flightSearch.depDate.MMDDYYYY').send_keys('12/31/2010') + time.sleep(1) + try: getid('idclose').click() + except NoSuchElementException: pass + else: time.sleep(1) + getid('SearchFlightBt').click() + while 1: + try: prcs = xpaths('//*[@class="fsCarouselCost"]') + except NoSuchElementException: time.sleep(1) + else: + minday = min((toprc(prc), day.get_text()) + for day, prc in + zip(xpaths('//*[@class="fsCarouselDate"]'), prcs)) + return toprc(prcs[3]), minday + +def jetblue(): + pass + +def bing(org, dst): + wd.get('http://bing.com/travel') + + getid('labelOW').click() + + getid('orig1Text').send_keys(org) + time.sleep(1) + getid('orig1Text').send_keys('\n') + + getid('dest1Text').send_keys(dst) + time.sleep(1) + getid('orig1Text').send_keys('\n') + + getid('no').click() + getid('ne').click() + getid('leave1').clear() + getid('leave1').send_keys('12/31/10') + time.sleep(1) + getid('submitBtn').click() + while 1: + # DEBUG map(toprc, xpaths('//table[@class="resultsTable"]//span[@class="price"]')) + try: return toprc(xpath('//table[@class="resultsTable"]//span[@class="price"]')) + except NoSuchElementException: time.sleep(1) + +def farecmp(): + pass + +def main(): + for org, dst in [('phl','sfo'),('ewr','sfo')]: + print 'united %r' % (united(org, dst),) + print 'aa %r' % (aa(org, dst),) + print 'bing %r' % (bing(org, dst),) + print 'virgin %r' % (virgin('jfk', 'sfo'),) + +main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-10-29 06:27:44
|
Revision: 1707 http://assorted.svn.sourceforge.net/assorted/?rev=1707&view=rev Author: yangzhang Date: 2010-10-29 06:27:37 +0000 (Fri, 29 Oct 2010) Log Message: ----------- Failed attempt to scrape united.com in Chickenfoot Added Paths: ----------- sandbox/trunk/src/misc/chickenfoot/ sandbox/trunk/src/misc/chickenfoot/unitedscrape.js Added: sandbox/trunk/src/misc/chickenfoot/unitedscrape.js =================================================================== --- sandbox/trunk/src/misc/chickenfoot/unitedscrape.js (rev 0) +++ sandbox/trunk/src/misc/chickenfoot/unitedscrape.js 2010-10-29 06:27:37 UTC (rev 1707) @@ -0,0 +1,44 @@ +// ==UserScript== +// @name ChaChaQuestionDisplayer +// @when Pages Match +// @description no description +// ==/UserScript== + +// This is a part of the scripts included with Chickenfoot for the read/write +// commands. +include('fileio.js'); + +function addJquery(callback) { + // Get the path to the profile in use. + var file = Components.classes["@mozilla.org/file/directory_service;1"] + .getService(Components.interfaces.nsIProperties) + .get("ProfD", Components.interfaces.nsIFile); + + var script = document.createElement('script'); + script.type = 'text/javascript'; + + // You can place the libraries any where you would like. This will just us + // the normal scripts directory for Chickenfoot. You could also source them + // to a web server. + script.innerHTML = read(file.path + '/chickenfoot/jquery-1.4.3.js'); + + document.getElementsByTagName('head')[0].appendChild(script); + $ = chromeWindow.content.wrappedJSObject.jQuery; +} + +function testUnited() +{ + go('http://united.com'); + wait(); + addJquery(); + $('#shop_from0_temp').val('ewr'); + $('#shop_to0_temp').val('sfo'); + $('#fromnearby1').click(); + $('#tonearby1').click(); + $('#wayOne').click(); + $('#shop_depart0').click().val('12/31/10'); + $('#SearchByPRICE').click(); +//$('input[value="submit"]').click(); +} + +//testUnited(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-10-29 06:13:24
|
Revision: 1706 http://assorted.svn.sourceforge.net/assorted/?rev=1706&view=rev Author: yangzhang Date: 2010-10-29 06:13:18 +0000 (Fri, 29 Oct 2010) Log Message: ----------- WebDriver demo Added Paths: ----------- sandbox/trunk/src/py/webdrivertest.py Added: sandbox/trunk/src/py/webdrivertest.py =================================================================== --- sandbox/trunk/src/py/webdrivertest.py (rev 0) +++ sandbox/trunk/src/py/webdrivertest.py 2010-10-29 06:13:18 UTC (rev 1706) @@ -0,0 +1,22 @@ +from selenium.firefox.webdriver import WebDriver +import time + +def blah(): + wd = WebDriver() + + def xpath(x): return wd.find_element_by_xpath(x) + def getid(x): return wd.find_element_by_id(x) + + wd.get('http://united.com') + getid('shop_from0_temp').send_keys('ewr') + getid('shop_to0_temp').send_keys('sfo') + getid('fromnearby1').click() + getid('tonearby1').click() + getid('wayOne').click() + time.sleep(1) + getid('shop_depart0').send_keys('12/31/10') + time.sleep(1) + getid('SearchByPRICE').click() + getid('sideform').submit() + + return wd This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-10-08 06:24:39
|
Revision: 1705 http://assorted.svn.sourceforge.net/assorted/?rev=1705&view=rev Author: yangzhang Date: 2010-10-08 06:24:33 +0000 (Fri, 08 Oct 2010) Log Message: ----------- Re-raising exceptions in Python Added Paths: ----------- sandbox/trunk/src/py/reraise.py Added: sandbox/trunk/src/py/reraise.py =================================================================== --- sandbox/trunk/src/py/reraise.py (rev 0) +++ sandbox/trunk/src/py/reraise.py 2010-10-08 06:24:33 UTC (rev 1705) @@ -0,0 +1,47 @@ +import sys + +# How to re-raise exceptions while preserving the original traceback (or not). +# Only relevant for older Pythons; Python 3 (and maybe 2.7) have +# Exception.__traceback__ and also exception chaining ("raise Exception(...) +# from caught_exception"). + +def f(): + raise Exception() + +# preserves original traceback +def g(): + try: + f() + except: + a,b,c = sys.exc_info() + raise a,b,c + +# preserves original traceback +def h(): + try: f() + except: raise + +# loses original traceback +def i(): + try: f() + except Exception as ex: raise ex + +# preserves original traceback +def j(): + try: + f() + except Exception as ex: + # Python recognizes the first element as an instance and not a type + raise ex, None, sys.exc_info()[2] + +try: g() +except: sys.excepthook(*sys.exc_info()) + +try: h() +except: sys.excepthook(*sys.exc_info()) + +try: i() +except: sys.excepthook(*sys.exc_info()) + +try: j() +except: sys.excepthook(*sys.exc_info()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-10-06 01:17:13
|
Revision: 1704 http://assorted.svn.sourceforge.net/assorted/?rev=1704&view=rev Author: yangzhang Date: 2010-10-06 01:17:06 +0000 (Wed, 06 Oct 2010) Log Message: ----------- finally and exceptions Added Paths: ----------- sandbox/trunk/src/py/finally_exceptions.py Added: sandbox/trunk/src/py/finally_exceptions.py =================================================================== --- sandbox/trunk/src/py/finally_exceptions.py (rev 0) +++ sandbox/trunk/src/py/finally_exceptions.py 2010-10-06 01:17:06 UTC (rev 1704) @@ -0,0 +1,7 @@ +try: + raise Exception('a') +finally: + try: + raise Exception('b') + except: + pass This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-09-27 18:29:54
|
Revision: 1703 http://assorted.svn.sourceforge.net/assorted/?rev=1703&view=rev Author: yangzhang Date: 2010-09-27 18:29:47 +0000 (Mon, 27 Sep 2010) Log Message: ----------- Tweaked links Modified Paths: -------------- personal-site/trunk/src/index.txt Modified: personal-site/trunk/src/index.txt =================================================================== --- personal-site/trunk/src/index.txt 2010-09-17 08:37:17 UTC (rev 1702) +++ personal-site/trunk/src/index.txt 2010-09-27 18:29:47 UTC (rev 1703) @@ -2,7 +2,7 @@ % Yang Zhang <div style="font-weight: bold"> - <span id="email"></span> | [Google (Buzz) Profile] | [Blog] + <span id="email"></span> | [Google (Buzz) Profile] | [Twitter] | [Blog] </div> <a name="about"></a> @@ -29,15 +29,14 @@ [MIT]: http://mit.edu/ [UC Berkeley]: http://berkeley.edu/ -- [Google (Buzz) profile]: includes my Google Reader shared items---probably my - most popular web property---as well as my blog entries, bookmarks, and tweets +- [Google (Buzz) profile]: includes my Google Reader shared items +- [Twitter] - [Blog] - [Delicious Bookmarks]: Mirrors my Google Bookmarks using [gbookmark2delicious]. I post articles, software, projects, services, homepages, and anything else of non-transient noteworthiness that I come across. - [Notes Wiki]: My pile of notes, mostly on computer science. -- [Twitter](http://www.twitter.com/yaaang) - [Facebook](http://www.facebook.com/yaaang) - [LinkedIn](http://www.linkedin.com/in/yzhang) - [GitHub](http://github.com/yang/) @@ -51,6 +50,7 @@ [gbookmark2delicious]: http://gbookmark2delicious.googlecode.com/ [GPG Key]: yang.gpg.asc [MIT PKS entry]: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xB1E65B60 +[Twitter]: http://www.twitter.com/yaaang <a name="projects"></a> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |