Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75615
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <badouglas@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:error': 0.03; 'resulting': 0.04; 'elif': 0.05; 'output': 0.05; '-if': 0.07; 'indicated': 0.07; 'skip:u 30': 0.07; '"__main__":': 0.09; '#print': 0.09; '__name__': 0.09; 'exception,': 0.09; 'inserted': 0.09; 'logic': 0.09; 'skip:# 30': 0.09; 'skip:$ 20': 0.09; 'skip:$ 30': 0.09; 'skip:/ 10': 0.09; 'try:': 0.09; 'sfxlen:2': 0.11; "wouldn't": 0.14; '"error': 0.16; '"thanks': 0.16; '-check': 0.16; '-create': 0.16; 'block.': 0.16; 'func': 0.16; 'operates': 0.16; 'res': 0.16; 'skip:n 50': 0.16; 'skip:z 40': 0.16; 'subject:exception': 0.16; 'exception': 0.16; 'skip:# 20': 0.16; 'skip:= 10': 0.16; 'wrote:': 0.18; 'app': 0.19; 'work,': 0.20; 'thanks.': 0.20; 'appears': 0.22; 'input': 0.22; 'aug': 0.22; 'bruce': 0.22; 'separate': 0.22; 'print': 0.22; 'error': 0.23; 'parse': 0.24; 'subject:/': 0.26; 'url:edu': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'idea': 0.28; 'am,': 0.29; 'quickly': 0.29; 'errors': 0.30; 'returned': 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; "i'm": 0.30; 'code': 0.31; 'getting': 0.31; 'posting': 0.31; 'app.': 0.31; 'struct': 0.31; 'file': 0.32; 'checked': 0.32; 'skip:c 30': 0.32; "we're": 0.32; 'run': 0.32; 'to:addr:tutor': 0.33; 'running': 0.33; 'skip:# 10': 0.33; 'could': 0.34; 'created': 0.35; 'except': 0.35; 'skip:s 30': 0.35; 'skip:u 20': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'var': 0.36; "didn't": 0.36; 'thanks': 0.36; 'possible': 0.36; 'so,': 0.37; 'list': 0.37; 'level': 0.37; 'skip:o 20': 0.38; 'process,': 0.38; 'to:addr:python-list': 0.38; 'skip:- 10': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'skip:n 30': 0.60; 'tell': 0.60; 'skip:t 30': 0.61; 'entire': 0.61; 'information': 0.63; 'decided': 0.64; 'determine': 0.67; 'skip:r 40': 0.68; 'skip:r 30': 0.69; 'college,': 0.84; 'intending': 0.84; 'personally.': 0.84; 'skip:/ 30': 0.84; 'subject:try': 0.84; 'valid,': 0.84; 'capture': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=wTKdxXPTQzeF89K8gPSWnCc6PoXbS6n4z4THXOIuu0Q=; b=ZKSYD6iXJ++U3jfPsqf4i7B1zDmFpLAEVFDfKCHGwS8LMZ/GJdh0lApy3H+O+e/TDp 2qBhsjSjZyg7A01BKCbeiSUAdd15Wvka43/nxxmdRKmZN05C676nhalDjhJFboQtAu0b k79KupFY3fvV24488xoXaXonBRMaiifkvZzzSZKG4ladSxj32sqGuJFoNwRPKf1l950S DFF4NZSUhheYu80TFA/dT8x7+9Jy2FA+ntqp04/MimQHTk4/u3lSQSp4yF0P0R6ZJt/K lzjwXZckw+maA92MaggqySoM7Uk/mzBFKnquDk37eVIc8yb0JY7861Cr1pD5sTxSo64h 99rA== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.111.167 with SMTP id ij7mr28837621igb.49.1407088333196; Sun, 03 Aug 2014 10:52:13 -0700 (PDT) |
| In-Reply-To | <CAP16ngohN8fNsX9CDPuRoXTuq3N89MWDfxqgHK-td-VzztErTw@mail.gmail.com> |
| References | <CAP16ngohN8fNsX9CDPuRoXTuq3N89MWDfxqgHK-td-VzztErTw@mail.gmail.com> |
| Date | Sun, 3 Aug 2014 13:52:13 -0400 |
| Subject | Re: try/exception - error block |
| From | bruce <badouglas@gmail.com> |
| To | Python Tutor Mailing List <tutor@python.org>, python-list@python.org |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12593.1407088336.18130.python-list@python.org> (permalink) |
| Lines | 263 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1407088336 news.xs4all.nl 2871 [2001:888:2000:d::a6]:47641 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:75615 |
Show key headers only | View raw
chris.. my bad.. I wasnt intending to mail you personally.
Or I wouldn't have inserted the "thanks guys"!
> thanks guys...
>
> but in all that.. no one could tell me .. why i'm not getting any
> errs/exceptions in the err file which gets created on the exception!!!
>
> but thanks for the information on posting test code!
Don't email me privately - respond to the list :)
Also, please don't top-post.
ChrisA
On Sun, Aug 3, 2014 at 10:29 AM, bruce <badouglas@gmail.com> wrote:
> Hi.
>
> I have a long running process, it generates calls to a separate py
> app. The py app appears to generate errors, as indicated in the
> /var/log/messages file for the abrtd daemon.. The errors are
> intermittent.
>
> So, to quickly capture all possible exceptions/errors, I decided to
> wrap the entire "main" block of the test py func in a try/exception
> block.
>
> This didn't work, as I'm not getting any output in the err file
> generated in the exception block.
>
> I'm posting the test code I'm using. Pointers/comments would be helpful/useful.
>
> ////////////////////
> the if that gets run is the fac1 logic which operates on the input
> packet/data..
> elif (level=='collegeFaculty1'):
> #getClasses(url, college, termVal,termName,deptName,deptAbbrv)
> ret=getParseCollegeFacultyList1(url,content)
> ////////////////////
>
> Thanks.
>
> if __name__ == "__main__":
> # main app
>
> try:
> #college="asu"
> #url="https://webapp4.asu.edu/catalog"
> #termurl="https://webapp4.asu.edu/catalog/TooltipTerms.ext"
>
>
> #termVal=2141
> #
> # get the input struct, parse it, determine the level
> #
>
> #cmd='cat /apps/parseapp2/asuclass1.dat'
> #print "cmd= "+cmd
> #proc=subprocess.Popen(cmd, shell=True,stdout=subprocess.PIPE)
> #content=proc.communicate()[0].strip()
> #print content
> #sys.exit()
>
> #s=getClasses(content)
>
> #print "arg1 =",sys.argv[0]
> if(len(sys.argv)<2):
> print "error\n"
> sys.exit()
>
> a=sys.argv[1]
> aaa=a
>
> #
> # data is coming from the parentApp.php
> # data has been rawurlencode(json_encode(t))
> # -reverse/split the data..
> # -do the fetch,
> # -save the fetched page/content if any
> # -create the returned struct
> # -echo/print/return the struct to the
> # calling parent/call
> #
>
> ##print urllib.unquote_plus(a).decode('utf8')
> #print "\n"
> #print simplejson.loads(urllib.unquote_plus(a))
> z=simplejson.loads(urllib.unquote_plus(a))
> ##z=simplejson.loads(urllib.unquote(a).decode('utf8'))
> #z=simplejson.loads(urllib2.unquote(a).decode('utf8'))
>
> #print "aa \n"
> print z
> #print "\n bb \n"
>
> #
> #-passed in
> #
> url=str(z['currentURL'])
> level=str(z['level'])
> cname=str(z['parseContentFileName'])
>
>
> #
> # need to check the contentFname
> # -should have been checked in the parentApp
> # -check it anyway, return err if required
> # -if valid, get/import the content into
> # the "content" var for the function/parsing
> #
>
> ##cmd='echo ${yolo_clientFetchOutputDir}/'
> cmd='echo ${yolo_clientParseInputDir}/'
> #print "cmd= "+cmd
> proc=subprocess.Popen(cmd, shell=True,stdout=subprocess.PIPE)
> cpath=proc.communicate()[0].strip()
>
> cname=cpath+cname
> #print "cn = "+cname+"\n"
> #sys.exit()
>
>
> cmd='test -e '+cname+' && echo 1'
> #print "cmd= "+cmd
> proc=subprocess.Popen(cmd, shell=True,stdout=subprocess.PIPE)
> c1=proc.communicate()[0].strip()
>
> if(not c1):
> #got an error - process it, return
> print "error in parse"
>
> #
> # we're here, no err.. got content
> #
>
> #fff= "sdsu2.dat"
> with open(cname,"r") as myfile:
> content=myfile.read()
> myfile.close()
>
>
> #-passed in
> #college="louisville"
> #url="http://htmlaccess.louisville.edu/classSchedule/"
> #termVal="4138"
>
>
> #print "term = "+str(termVal)+"\n"
> #print "url = "+url+"\n"
>
> #jtest()
> #sys.exit()
>
> #getTerm(url,college,termVal)
>
>
> ret={} # null it out to start
> if (level=='rState'):
> #ret=getTerm(content,termVal)
> ret=getParseStates(content)
>
> elif (level=='stateCollegeList'):
> #getDepts(url,college, termValue,termName)
> ret=getParseStateCollegeList(url,content)
>
> elif (level=='collegeFaculty1'):
> #getClasses(url, college, termVal,termName,deptName,deptAbbrv)
> ret=getParseCollegeFacultyList1(url,content)
>
> elif (level=='collegeFaculty2'):
> #getClasses(url, college, termVal,termName,deptName,deptAbbrv)
> ret=getParseCollegeFacultyList2(content)
>
>
>
> #
> # the idea of this section.. we have the resulting
> # fetched content/page...
> #
>
> a={}
> status=False
> if(ret['status']==True):
>
> s=ascii_strip(ret['data'])
> if(((s.find("</html")>-1) or (s.find("</HTML")>-1)) and
> ((s.find("<html")>-1) or (s.find("<HTML")>-1)) and
> level=='classSectionDay'):
>
> status=True
> #print "herh"
> #sys.exit()
>
> #
> # build the returned struct
> #
> #
>
> a['Status']=True
> a['recCount']=ret['count']
> a['data']=ret['data']
> a['nextLevel']=''
> a['timestamp']=''
> a['macAddress']=''
> elif(ret['status']==False):
> a['Status']=False
> a['recCount']=0
> a['data']=''
> a['nextLevel']=''
> a['timestamp']=''
> a['macAddress']=''
>
> res=urllib.quote(simplejson.dumps(a))
> ##print res
>
> name=subprocess.Popen('uuidgen -t', shell=True,stdout=subprocess.PIPE)
> name=name.communicate()[0].strip()
> name=name.replace("-","_")
>
>
> ## if status==True:
> name2=tmpParseDir+"/rr_"+name+".dat"
> ofile1=open(name2,"w+")
> ofile1.write(res)
> ofile1.close()
> print name2
>
> if status==False:
> sname=tmpParseDir+"/serr_"+name+".dat"
> ofile1=open(sname,"w+")
> ofile1.write(aaa)
> ofile1.close()
>
>
> sys.exit()
>
>
>
>
> print "term = "+str(termVal)+"\n"
> print "url = "+url+"\n"
>
> getTerm(url,college,termVal)
>
>
> print "exit"
> sys.exit()
>
> except Exception, e:
> print e
> print "pycolFac1 - error!! \n";
> name=subprocess.Popen('uuidgen -t', shell=True,stdout=subprocess.PIPE)
> name=name.communicate()[0].strip()
> name=name.replace("-","_")
> name2="/home/ihubuser/parseErrTest/pp_"+name+".dat"
> ofile1=open(name2,"w+")
> ofile1.write(e)
> ofile1.write(aaa)
> ofile1.close()
>
> sys.exit()
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: try/exception - error block bruce <badouglas@gmail.com> - 2014-08-03 13:52 -0400
csiph-web