def getArticle():
    global count
    print("Fetching Article " + str(count) + " ........")
    count = count + 1
    # print(base_url+"/international/")
    article_links = getData()
    if not article_links:
        t1 = timer(60 * minutes, getArticle)
        t1.start()
    article_link = choice(article_links)
    # print(article_link)
    # print(base_url+article_link)
    article_soup = bs(urlopen(base_url + article_link), "lxml")

    p_tags = article_soup.find_all("p")
    with open(file_name, "w") as file:
        header = findall(pattern=">(.*)<",
                         string=str(article_soup.find_all("h1")))
        file.write(header[0].encode('utf-8') + "\n\n")
        for p in p_tags:
            txt = p.getText().encode('utf-8')
            file.write(txt + "\n")

    Popen(['start', 'Article.txt'], shell=True)
    t = timer(60 * minutes, getArticle)
    t.start()
Ejemplo n.º 2
0
def ipmi():
    print("QvQ")
    info = subprocess.check_output(cmd).decode('utf-8')
    for l in info.splitlines():
        if 'degrees C' in l:
            print(l)
    sys.stdout.flush()
    t = timer(0.8, ipmi)
    t.start()
Ejemplo n.º 3
0
	def do_loop(self):
		# Take care to the closure here (ie. self._log)
		if self._log: self._log.info(f'luminosity {self._addr} enabled')
		def lumi():
			status = self.status_frame()
			if self._log: self._log.info(f'sending luminosity: {self.subject()}: {dump_as_json(status)}')
			self.send(status)
			self._timer = timer(10, lumi)
			self._timer.start()
		self._timer = timer(10, lumi)
		self._timer.start()
		self._backend.do_loop()
def blockIP(clientIP):
    global banTime
    #   Make sure ban time is set to XX minutes
    if banTime != 0:
        netFilterCommand = "iptables -A INPUT -s %s -j DROP" % str(clientIP)
        os.system(netFilterCommand)
        #   here we are checking for banTime seconds using a thread timer
        #   more efficient for system handling. Once the time is reached, 
        #   the thread will call on the unblock function
        #   threading.timer(Time,function to call, argument)
        timer = threading.timer(banTime,unblockIP(),clientIP)
        timer.start()
        print ("User: "******" has been banned from logging into you machine for " + banTime + " minutes")
Ejemplo n.º 5
0
	def move_monster(self):
		random_x = random.randint(0,3)
		random_y = random.randint(0,2)
		self.position = all_rooms[random_x][random_y]
		print(monster.position)
		if flamie.position == monster.position:
			os.system("color 04")
			time.sleep(5)
			if flamie.position == monster.position:
				print("you died!!")
				time.sleep(1.25)
				exit()
		dunk_timer = timer(5, self.move_monster)
		dunk_timer.start()
Ejemplo n.º 6
0
 def down(self):
     if self._order == 'down':
         return
     self._order = 'down'
     if self._status != 'close':
         self._status = 'between'
         self._timer_cond.acquire()
         if self._timer:
             self._timer.cancel()
         self._timer = timer(30, self.on_complete, ('close', ))
         self._timer.start()
         self._timer_cond.release()
         gpio.output(self._pin_up, gpio.HIGH)
         gpio.output(self._pin_up, gpio.LOW)
Ejemplo n.º 7
0
 def up(self):
     if self._order == 'up':
         return
     self._order = 'up'
     if self._status != 'open':
         self._status = 'between'
         self._timer_cond.acquire()
         if self._timer:
             self._timer.cancel()
         self._timer = timer(10, self.on_complete, ('open', ))
         self._timer.start()
         self._timer_cond.release()
         gpio.output(self._pin_up, gpio.LOW)
         gpio.output(self._pin_up, gpio.HIGH)
Ejemplo n.º 8
0
		def lumi():
			status = self.status_frame()
			if self._log: self._log.info(f'sending luminosity: {self.subject()}: {dump_as_json(status)}')
			self.send(status)
			self._timer = timer(10, lumi)
			self._timer.start()
Ejemplo n.º 9
0
 def sync(self, slot_len=10 * 10 ^ -3, number_slots=1):
     count = 0
     while count <= number_slots:
         obj = signal_slots()
         t = timer(slot_len, obj.connect_slot, [count])
         t.start()
Ejemplo n.º 10
0
    def _start(self, interval: int, function):

        self.interval = interval
        self.function = function
        self.thread = timer(self.interval, self.loop)
        self.thread.start()
Ejemplo n.º 11
0
    def loop(self):

        self.function(self.interval)
        self.thread = timer(self.interval, self.loop)
        self.thread.start()
Ejemplo n.º 12
0
def standupEnd(data, channel_id, u_id, finish):
    threading.timer(finish, standupNotActive(data, channel_id, u_id)).start()
    post_message(data['channels']['channel_id']['standup_message'], channel_id)
Ejemplo n.º 13
0
import sys
import subprocess
from threading import Timer as timer

cmd = ["ipmitool", "sensor"]


def ipmi():
    print("QvQ")
    info = subprocess.check_output(cmd).decode('utf-8')
    for l in info.splitlines():
        if 'degrees C' in l:
            print(l)
    sys.stdout.flush()
    t = timer(0.8, ipmi)
    t.start()


t = timer(0.8, ipmi)
t.start()
#while True:
#	pass