Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import threading
- from threading import Timer
- class cron(object):
- def __init__(self, interval, function, *args, **kwargs):
- self._timer = None
- self.interval = interval
- self.function = function
- self.args = args
- self.kwargs = kwargs
- self.is_running = False
- self.start()
- def _run(self):
- self.is_running = False
- self.start()
- self.function(*self.args, **self.kwargs)
- def start(self):
- if not self.is_running:
- self._timer = Timer(self.interval, self._run)
- self._timer.start()
- self.is_running = True
- def stop(self):
- self._timer.cancel()
- self.is_running = False
- from time import sleep
- def hello(name):
- print "Hello %s!" % name
- print "starting..."
- rt = cron(1, hello, "World") # it auto-starts, no need of rt.start()
- try:
- sleep(5) # your long-running job goes here...
- print "serving...."
- print(' ')
- print(' ')
- import socket
- googleip=socket.gethostbyname('www.google.com')
- print 'Google public IP address is:', googleip
- print('********************************************')
- yourdomain_hn_ip=socket.gethostbyname('yourdomain.hn.org')
- print 'yourdomain.hn.ip public IP address is:', yourdomain_hn_ip
- print('********************************************')
- import urllib
- mypublicip = urllib.urlopen('http://www.biranchi.com/ip.php').read()
- print 'My public ip is :', mypublicip
- print(' ')
- print(' ')
- finally:
- rt.stop() # better in a try/finally block to make sure the program ends!
- print "starting..."
- #----------------------------------------------------------------------------
- # This example requires the requests library be installed. You can learn more
- # about the Requests library here: http://docs.python-requests.org/en/latest/
- print(' ')
- print(' ')
- import socket
- googleip=socket.gethostbyname('www.google.com')
- print 'Google public IP address is:', googleip
- print('********************************************')
- kenya_hn_ip=socket.gethostbyname('kenya.hn.org')
- print 'kenya.hn.ip public IP address is:', kenya_hn_ip
- print('********************************************')
- import urllib
- mypublicip = urllib.urlopen('http://www.biranchi.com/ip.php').read()
- print 'My public ip is :', mypublicip
- print(' ')
- print(' ')
- import mechanize
Advertisement
Add Comment
Please, Sign In to add comment