Python import value if module fails -


i've written small python program. executed every 15 minutes running main.py, loads 2 other python scripts modules.

the problem when 1 module fails (for example because of lost internet connection). 1 of modules parses feed internet. if fails, has assume value. problem import value main.py.

the module:

[...] feed=feedparser.parse(url)  if not feed.feed:     # assume error     print("error")     temperature = 20     print 'assuming', temperature, 'degrees c'     sys.exit()  temperature = [...] 

when cause module fail, main.py exits after module import. how fix this?

i think caused calling sys.exit(), dont know else function should call?

thanks...

in python can have in try except block:

try:     import modulea except importerror,e:     import moduleb 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -