Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Implement main()

  • Loading branch information...
commit bf27008c9af5a1ad81b52d3aa29aebc813115438 1 parent a0a5fec
Pete Zaitcev authored

Showing 1 changed file with 27 additions and 28 deletions. Show diff stats Hide diff stats

  1. +27 28 hailcamsnap.py
55 hailcamsnap.py
@@ -161,31 +161,30 @@ def config(cfgname, inisect):
161 161 return cfg
162 162
163 163 # main()
164   -# def main(args):
165   -
166   -argc = len(sys.argv)
167   -if argc == 1:
168   - cfgname = "hailcamsnap.ini"
169   -elif argc == 2:
170   - cfgname = sys.argv[1]
171   -else:
172   - print >>sys.stderr, "Usage: hailcamsnap [hailcamsnap.ini]"
173   - sys.exit(1)
174   -
175   -try:
176   - cfg = config(cfgname, "snap")
177   -except ConfigError, e: # This is our exception. Other types traceback.
178   - print >>sys.stderr, "Error in config file " + cfgname + ":", e
179   - sys.exit(1)
180   -
181   -t = SnapScript(cfg)
182   -while 1:
183   - rc = t.fetch()
184   - if rc == 0:
185   - t.upload()
186   - print "Sleeping %(ss)gs" % { 'ss' : cfg["sleepval"] }
187   - time.sleep(cfg["sleepval"])
188   -
189   -## http://utcc.utoronto.ca/~cks/space/blog/python/ImportableMain
190   -#if __name__ == "__main__":
191   -# main(sys.argv[1:])
  164 +def main(args):
  165 + argc = len(args)
  166 + if argc == 1:
  167 + cfgname = "hailcamsnap.ini"
  168 + elif argc == 2:
  169 + cfgname = sys.argv[1]
  170 + else:
  171 + print >>sys.stderr, "Usage: hailcamsnap [hailcamsnap.ini]"
  172 + sys.exit(1)
  173 +
  174 + try:
  175 + cfg = config(cfgname, "snap")
  176 + except ConfigError, e: # This is our exception. Other types traceback.
  177 + print >>sys.stderr, "Error in config file " + cfgname + ":", e
  178 + sys.exit(1)
  179 +
  180 + t = SnapScript(cfg)
  181 + while 1:
  182 + rc = t.fetch()
  183 + if rc == 0:
  184 + t.upload()
  185 + print "Sleeping %(ss)gs" % { 'ss' : cfg["sleepval"] }
  186 + time.sleep(cfg["sleepval"])
  187 +
  188 +# http://utcc.utoronto.ca/~cks/space/blog/python/ImportableMain
  189 +if __name__ == "__main__":
  190 + main(sys.argv)

0 comments on commit bf27008

Please sign in to comment.
Something went wrong with that request. Please try again.