예제 #1
0
def handleQuota():
   quota = int(data.get("quota"))###
   if quota == 1:
      data.set("quota", 0)
      print "quota set 0"
      leftQuota()
   return 1
예제 #2
0
 def add(self):
     parser = argparse.ArgumentParser(
         description='Add a new url to capsule')
     group = parser.add_mutually_exclusive_group()
     parser.add_argument('url', help="Url to be saved")
     group.add_argument('-n', '--name', help="Alias for repo")
     args = parser.parse_args(sys.argv[2:])
     url = args.url
     name = args.name
     db.set(url, name=name)
예제 #3
0
 def trenutniZadatakList(self):
     list = []
     self.cur.execute("SELECT * FROM trenutniZadatak")
     row = self.cur.fetchone()
     while row is not None:
         data = zadatak.NkTrenutniZadatak()
         data.set(row[0],row[1],row[2],row[3],row[4],row[5])
         list.append(data)
         row = self.cur.fetchone()   
     return list 
예제 #4
0
def handleIcon():
   global icon
   global ka
   
   cicon = int(data.get("icon"))
   if not cicon == icon:
      data.set("icon", icon)
      print "Icon set", icon
      ka.kill()
      ka = subprocess.Popen(['python', 'appIndicator.py'])
   return 1
예제 #5
0
def handleCheck():
   global icon
   
   check = int(data.get("check"))
   if check == 1:
      data.set("check", 0)
      print "check set 0"
      
      newMail = int(checkMail())
      
      if newMail == 0:
         icon = 1
      else:
         icon = 4
      
      if newMail == 0:
         os.system('notify-send -i /usr/share/icons/METUnotifyIcons/email.png "No New Mail" "There is no new mail."')
      else:
         os.system('notify-send -i /usr/share/icons/METUnotifyIcons/email.png "New Mail" "'+str(newMail)+' unread mail."')
   return 1
예제 #6
0
async def update():
    while True:
        try:
            sheet = data.get()

            changed = False
            while int(sheet[0][0]) > int(sheet[0][1]):
                row = int(sheet[0][1])
                changed = True
                for i in range(0, len(sheet[row]), 2):
                    if sheet[row - 1][i] != sheet[row][i]:
                        msg = f'**{sheet[row][i + 1]}** has bid **{sheet[row][i]}** on response **{responses[i // 2]}**!'
                        await channel.send(msg)
                        print(msg)
                sheet[0][1] = row + 1

            if changed:
                data.set(sheet[0][1])
        except Exception as e:
            print(f'ERROR: {e}')

        await asyncio.sleep(5)
예제 #7
0
def quotaCheck(item):
    controlmain()
    data.set("quota", 1)
    print "quota set 1"
예제 #8
0
def mailCheck(item):
    controlmain()
    data.set("check", 1)
    print "check set 1"
예제 #9
0
#!/usr/bin/python
import mechanize
import subprocess, data, os
from time import time, sleep

os.chdir(os.path.dirname(os.path.abspath(__file__)))

# Check if user trying to open more than 2 program at the same time
output = os.popen("cat /proc/"+data.get("pid")+"/cmdline").read()
if "METUnotify" in output:
   os.system('notify-send -i /usr/share/icons/METUnotifyIcons/fail.png "Already Running" "Your program already running."')
   exit(0)

data.setAllZero()
data.set("pid", str(os.getpid()))
print "P.ID:",os.getpid()

username  = data.getup(0)
password  = data.getup(1)
browser = mechanize.Browser() # Browser which we handle our stuffs
reFreq = 60 # Refresh frequency as second
icon = 1 
ka = 0 # Will be variable of subprocess of appIndicator.py

def checkConnection(reference='https://horde.metu.edu.tr/'):
   try:
      browser.open(reference)
      return 1
   except:
      pass