Posts

What is the point of setLevel in a python logging handler? -

let's have following code: import logging import logging.handlers = logging.getlogger('myapp') h = logging.handlers.rotatingfilehandler('foo.log') h.setlevel(logging.debug) a.addhandler(h) # effective log level still logging.warn print a.geteffectivelevel() a.debug('foo message') a.warn('warning message') i expect setting logging.debug on handler cause debug-level messages written log file. however, prints 30 effective level (equal logging.warning , default), , logs warn message log file, not debug message. it appears handler's log level being dropped on floor, e.g. it's silently ignored. makes me wonder, why have setlevel on handler @ all? it allows finer control. default root logger has warning level set, means wont print messages lower level(no matter how handlers' levels set!). but, if set root logger's level debug , indeed message sent log file: import logging import logging.handlers = logging.getlogg...

javascript - What does a ScriptManager script reference do? -

on previous project working on, noticed javascript files included inside script manager so: <asp:scriptreference path="~/scripts/jquery-1.7.1.min.js" /> <asp:scriptreference path="~/scripts/site.js" /> i've tried searching difference between script reference , regular <script src="/> in asp page can't seem find information. there advantage using script reference? thanks when using scriptmanager single composite script can created reduce number of browser requests asp.net. you can refer scriptreference class also about section of scriptmanager tells more details it: scriptmanager asp.net control manages asp.net ajax script libraries. scriptmanager performs following functions. enables partial page rendering eanbles client side script access web services enables use of authenication , profile services client only 1 scriptmanager can allowed per page. scenarios second scriptman...

python - Reading a RAW image (.CR2) using numpy.fromfile -

i trying read raw image in .cr2 format ("canon raw format"). wanted opencv not work tried doing numpy function: img = np.fromfile('img.cr2', "uint16") the camera canon eos t5 18mp dslr. if run img.size return 10105415 seems small 18 mp camera. my first question, using np.fromfile() valid approach? secondly, recommend other python libraries same process in easier way/more efficient? have opencv installed if done there, great (i still want store numpy array). canon raw format not blob of data, has metadata need parse. luckily, others have implemented python parsers. raw image processing in python after using 1 of suggested solutions can load data numpy array.

ruby - Using cloc (count Lines of Codes) result -

i writing script research, , want total number of lines in source file. came around cloc , think going use in script. however, cloc gives result many information (unfortunately since new member cannot upload photo). gives number of files, number of lines, number of blank lines, number of comment lines, , other graphical representation stuff. i interested in number of lines use on calculations. there way number (maybe performing options in command line (although went through available options , didn't find useful case))? i thought regular expression on result number; however, first time using cloc , there might better/professional way of doing it. any thought? regards, arwa i not sure cloc. worth using default shell command. please have @ this question . number of lines of code individually find . -name '*.*' | xargs wc -l to total number of lines of code in directory. (find ./ -name '*.*' -print0 | xargs -0 cat) | wc -l please note ...

How to create rewrite rule to Rename PDF file on the fly while Downloading using nginx? -

i working on site allowing users download pdf files. each pdf file stored on server using random hash names, eg. file 768e1f881783bd61583d64422797632a35b6804c.pdf stored in /usr/share/nginx/html/contents/7/6/8/e/1/768e1f881783bd61583d64422797632a35b6804c.pdf now can try give users direct location of file , file name after being downloaded shown 768e1f881783bd61583d64422797632a35b6804c.pdf , rename file on fly, can achive using php this <?php // we'll outputting pdf header('content-type: application/pdf'); // called downloaded.pdf header('content-disposition: attachment; filename="downloaded.pdf"'); // pdf source in original.pdf readfile('original.pdf'); ?> ref: rename pdf file downloaded on fly but lloking nginx rules directly can rewrite download urls path , rename on fly. how can ? i have tried this. location ^/download-pdf { alias /usr/share/nginx/html/contents; if ($request_filename ~ ^.*?/[^/]*?_(.*?...

r - Why does summarise on grouped data result in only overall summary in dplyr? -

suppose have following data: dfx <- data.frame( group = c(rep('a', 8), rep('b', 15), rep('c', 6)), sex = sample(c("m", "f"), size = 29, replace = true), age = runif(n = 29, min = 18, max = 54) ) with old plyr can create little table summarizing data following code: require(plyr) ddply(dfx, .(group, sex), summarize, mean = round(mean(age), 2), sd = round(sd(age), 2)) the output this: group sex mean sd 1 f 49.68 5.68 2 m 32.21 6.27 3 b f 31.87 9.80 4 b m 37.54 9.73 5 c f 40.61 15.21 6 c m 36.33 11.33 i'm trying move code dplyr , %>% operator. code takes df group group , sex , summarise it. is: dfx %>% group_by(group, sex) %>% summarise(mean = round(mean(age), 2), sd = round(sd(age), 2)) but output is: mean sd 1 35.56 9.92 what doing wrong? thanks! the problem here loading dplyr first , plyr, plyr's function summarise ...

windows installer - How to detect that Wix bundle is being uninstalled? -

i have wix bootstrapper bundle installs couple of msi packages.i want delete registry values when bundle being uninstalled. problem values should deleted when whole bundle uninstalled (not 1 of msi packages). tried use wixbundleaction wix variable detect case , pass msiproperty packages, allways evaluates 0 <msipackage id="pac" sourcefile="$(var.so)" compressed="yes" vital="yes"> <msiproperty name="remove_reg" value="[wixbundleaction]"/> </msipackage> is there proper way detect when bundle uninstalling? the direct answer question bug 0, should fixed in latest build of v3.10 , v4.0. the real answer should doing registry operations inside msi, not bootstrapper. let windows installer keep track of ref counting, rollback, etc.