Пример #1
0
def main():
    if len(argv) < 2:
        print("Missing argument, specify window manager name")
        exit(1)

    wm = argv[1]
    home = path.expanduser("~")

    with open(path.join(home, ".theme", "theme.json")) as f:
        theme = json.load(f)[wm]

    subprocess.call([
        path.join(home, ".config", "alacritty", "theme.py"), theme["alacritty"]
    ])

    if wm == "qtile":
        qtile_theme_file = path.join(path.expanduser("~"), ".config", "qtile",
                                     "config.json")
        with open(qtile_theme_file) as f:
            qtile_config = json.load(f)
        qtile_config["theme"] = theme["wm"]
        with open(qtile_theme_file, "w") as f:
            json.dump(qtile_config, f)

    notification("Theme set!", "Theme")
Пример #2
0
def notify():
    config = Config()

    if config.notifications:
        print(Fore.RED + 'Notifications disabled' + Style.RESET_ALL, end=' ')
        # notification('Notifications disabled', title='Autoskipper')
    else:
        print(Fore.GREEN + 'Notifications enabled' + Style.RESET_ALL, end=' ')
        notification('Notifications enabled', title='Autoskipper')
    config.notifications = not config.notifications
    config.write()
Пример #3
0
def on_message(client, userdata, msg):
    value = msg.payload.decode()
    print("Received: " + msg.topic + " " + str(value))
    if msg.topic == "sensor/" + CLIENT_ID + "/temp1/state":
        global CPU_hot
        if int(value) >= 45:
            if not CPU_hot:
                print("Emitting notification")
                notification("CPU exceeding 45°C")
                CPU_hot = True
        else:
            CPU_hot = False
Пример #4
0
def toggle():
    config = Config()

    if config.autoskip:
        print(Fore.RED + 'Autoskip disabled' + Style.RESET_ALL, end=' ')
        if config.notifications:
            notification('Autoskip disabled', title='Autoskipper')
    else:
        print(Fore.GREEN + 'Autoskip enabled' + Style.RESET_ALL, end=' ')
        if config.notifications:
            notification('Autoskip enabled', title='Autoskipper')
    config.autoskip = not config.autoskip
    config.write()
Пример #5
0
 def finished(self):
     if self.running_tasks:
         raise RuntimeError
     TaskQueue.finished(self)
     self.window.set_sensitive()
     self.window.conversion_ended()
     total_time = self.run_finish_time - self.run_start_time
     msg = _('Conversion done, in %s') % self.format_time(total_time)
     if self.error_count:
         msg += ', %d error(s)' % self.error_count
     self.window.set_status(msg)
     if not self.window.is_active():
         notification(msg) # this must move
     self.reset_counters()
Пример #6
0
 def finished(self):
     # This must be called with emit_async
     if self.running_tasks:
         raise RuntimeError
     TaskQueue.finished(self)
     self.window.set_sensitive()
     self.window.conversion_ended()
     total_time = self.run_finish_time - self.run_start_time
     msg = _('Conversion done in %s') % self.format_time(total_time)
     if self.error_count:
         msg += ', %d error(s)' % self.error_count
     self.window.set_status(msg)
     if not self.window.is_active():
         notification(msg)  # this must move
     self.reset_counters()
Пример #7
0
 def finished(self):
     # This must be called with emit_async
     if self.running_tasks:
         raise RuntimeError
     TaskQueue.finished(self)
     self.window.set_sensitive()
     self.window.conversion_ended()
     total_time = self.run_finish_time - self.run_start_time
     msg = _("Conversion done in %s") % self.format_time(total_time)
     if self.error_count:
         msg += ", %d error(s)" % self.error_count
     self.window.set_status(msg)
     if not self.window.is_active():
         notification(msg)  # this must move
     self.reset_counters()
Пример #8
0
 def boucle(Xpath):
     PATH = '.\chromedriver.exe'
     driver = webdriver.Chrome(PATH)
     driver.get('https://vente.tryandjudge.com/dofuskamas.php')
     
     
     while True:
         try:
             sell = driver.find_element_by_xpath(Xpath)        
             sell.click()
             notification('Jri jri rah t7aal',title="bi3 Kama")
                 
         except:
             print("Not yet")
             time.sleep(5)
             driver.refresh()
Пример #9
0
def wla():
    song = Song()
    song_config = SongConfig()
    current_song = song_config.create(song.artist)
    config = Config()

    if current_song["whitelisted"]:
        text = '{}Removed{} "' + song.artist + '" from whitelisted artists'
        colored_text = text.format(Fore.RED, Style.RESET_ALL)
    else:
        text = '{}Added{} "' + song.artist + '" to whitelisted artists'
        colored_text = text.format(Fore.GREEN, Style.RESET_ALL)

    current_song["whitelisted"] = not current_song["whitelisted"]
    text = text.format('', '')
    print(colored_text, end=' ')
    if config.notifications:
        notification(text, title='Autoskipper')
    song_config.write()
Пример #10
0
def wls():
    song = Song()
    song_config = SongConfig()
    current_song = song_config.create(song.artist)
    config = Config()

    if song.title in current_song["whitelisted_songs"]:
        current_song["whitelisted_songs"].remove(song.title)
        text = '{}Removed{} "' + song.title + '" from whitelisted songs'
        colored_text = text.format(Fore.RED, Style.RESET_ALL)
    else:
        current_song["whitelisted_songs"].append(song.title)
        text = '{}Added{} "' + song.title + '" to whitelisted songs'
        colored_text = text.format(Fore.GREEN, Style.RESET_ALL)

    text = text.format('', '')
    print(colored_text, end=' ')
    if config.notifications:
        notification(text, title='Autoskipper')
    song_config.write()
Пример #11
0
def main():
    parser = argparse.ArgumentParser(
        description=
        'Generates data set to train i3-eye by periodically capturing from the '
        'camera. Will capture every minute until process is killed')
    parser.add_argument('--dest',
                        required=True,
                        help='destination directory where to save '
                        'captured images. The name of the images '
                        'will be a date time stamp')
    flags = parser.parse_args()

    focus_left = random.choice([True, False])
    while True:
        notification(f"Capture in {WARNING_TIME} seconds. Look "
                     f"{'LEFT' if focus_left else 'RIGHT'}")
        time.sleep(WARNING_TIME)
        capture_frame(make_file_path(flags.dest, 'L' if focus_left else 'R'))
        focus_left = not focus_left

        time.sleep(DOWN_TIME)
Пример #12
0
def main():
    wm = argv[1]
    home = path.expanduser("~")

    with open(path.join(home, ".theme", "theme.json")) as f:
        theme = json.load(f)[wm]

    subprocess.call([
        path.join(home, ".config", "alacritty", "theme.py"), theme["alacritty"]
    ])

    if wm == "qtile":
        qtile_theme_file = path.join(path.expanduser("~"), ".config", "qtile",
                                     "config.json")
        with open(qtile_theme_file) as f:
            qtile_config = json.load(f)
        qtile_config["theme"] = theme["wm"]
        with open(qtile_theme_file, "w") as f:
            json.dump(qtile_config, f)

    notification("Theme set!", "Theme")
Пример #13
0
def notify(
    notifier,
    user: Optional[Union[str, int]] = None,
    to: Optional[Union[str, int]] = None,
    pw: Optional[str] = None,
    msg: Optional[str] = None,
):
    body = sys.stdin.read()[-2000:]
    if notifier == "telegram":
        import telegram

        bot = telegram.Bot(user)
        to = -int(to)
        bot.sendMessage(to, msg + "\n\n" + body)
    elif notifier == "yagmail":
        import yagmail

        yag = yagmail.SMTP(user, pw)
        yag.send(to=to, subject=msg, contents=body)
    elif notifier == "notify-send":
        from notify import notification

        notification(body, msg)
Пример #14
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--target-lang", default="pt", help="Target language.")
    parser.add_argument("--source-lang", default="en", help="Source language.")
    parser.add_argument("--notify",
                        action="store_const",
                        const=True,
                        help=help_notify)
    parser.add_argument("--text",
                        nargs="+",
                        help="Translates command line input text.")
    parser.add_argument(
        "--source-api",
        choices=["google", "mymemory"],
        default="google",
        help=help_source,
    )

    args = parser.parse_args()

    text = " ".join(args.text) if args.text else clip.get()

    translator = Translator(
        source_lang=args.source_lang,
        target_lang=args.target_lang,
        source_api=args.source_api,
    )

    translated_text = translator.translate(text)

    if args.notify:
        notification(translated_text, app_name="ztranslation")
    else:
        print(translated_text)

    clip.set(translated_text)
Пример #15
0
                                                #using the def ""char-write"")
        # list_handles[6] = period_handle - int
        # list_handles[7] = period_value - str
        #accel_list_handles = [52,'03','00',48,49,'0100',55,'10'] - for 10 milliseconds

accelerometer = sensor(sensor_tag,accel_list_handles,convert.accel)
gyroscope = sensor(sensor_tag,gyro_list_handles,convert.gyro)
magnetometer= sensor(sensor_tag,magneto_list_handles,convert.magneto)


#handle_name = [(0x0030,accel_convert),(0x0060,gyro_convert),(0x0046,magneto_convert)]

data_list_handles = ['0x0030','0x0060','0x0046']
dict_conv_func = {'0x0030':accelerometer.calculate,'0x0046':magnetometer.calculate,'0x0060':gyroscope.calculate}
                    
notif = notify.notification(sensor_tag,data_list_handles)

while True:
    time.sleep(.100)
    os.system('clear')
    raw_output = notif.parse_output()
    calc_output = {}

    #output_2 = dict([(handle,dict_conv_func[str(handle)](output[handle])) for handle in data_list_handles])
    for handle in data_list_handles:
        calc_output[handle] = dict_conv_func[handle](raw_output[handle])
    print calc_output


    
Пример #16
0
#using the def ""char-write"")
# list_handles[6] = period_handle - int
# list_handles[7] = period_value - str
#accel_list_handles = [52,'03','00',48,49,'0100',55,'10'] - for 10 milliseconds

accelerometer = sensor(sensor_tag, accel_list_handles, convert.accel)
gyroscope = sensor(sensor_tag, gyro_list_handles, convert.gyro)
magnetometer = sensor(sensor_tag, magneto_list_handles, convert.magneto)

#handle_name = [(0x0030,accel_convert),(0x0060,gyro_convert),(0x0046,magneto_convert)]

data_list_handles = ['0x0030', '0x0060', '0x0046']
dict_conv_func = {
    '0x0030': accelerometer.calculate,
    '0x0046': magnetometer.calculate,
    '0x0060': gyroscope.calculate
}

notif = notify.notification(sensor_tag, data_list_handles)

while True:
    time.sleep(.100)
    os.system('clear')
    raw_output = notif.parse_output()
    calc_output = {}

    #output_2 = dict([(handle,dict_conv_func[str(handle)](output[handle])) for handle in data_list_handles])
    for handle in data_list_handles:
        calc_output[handle] = dict_conv_func[handle](raw_output[handle])
    print calc_output
Пример #17
0
reddit = praw.Reddit(client_id=config.get("CLIENT_ID"),
                     client_secret=config.get('CLIENT_SECRET'),
                     user_agent=config.get('USER_AGENT'))

last_post_created = None

err = {'hasError': False, 'logged': False}

while True:
    if (err['hasError'] and not err['logged']):
        err['logged'] = True
        log_file.write(f'--- {datetime.now()} ----\n')
    log_file.write('Error occured retrying...\n\n')

    try:
        for submission in reddit.subreddit(
                config.get('SUBREDDIT')).new(limit=1):
            err['err'], err['logged'] = False, False
            if (submission.created_utc != last_post_created):
                notification(submission.name, summary=submission.title)
                last_post_created = submission.created_utc

                if (config.get('AUTO_OPEN', False)):
                    webbrowser.open(
                        f'http://reddit.com/{submission.permalink}')

    except:
        err['err'] = True

    time.sleep(config.get('POLL_INTERVAL'))
Пример #18
0
def test_notification_function():
    status = notification("hello world", message="optinal")
    assert status is True
Пример #19
0
def test_notification_function():
    notification("hello world", title="optinal")
Пример #20
0
                # Generate notification message.
                notification_message = "Found vaccine booking at {} {}".format(
                    location, date)

                # Send pushover notification, if pushover token is provided.
                if args.pushover_token or args.pushover_user:
                    pushover.notify(user=args.pushover_user,
                                    message=notification_message,
                                    token=args.pushover_token)

                # Send system notification, depending on platform.
                if notification_platform == 'darwin':
                    pync.notify(notification_message)
                elif notification_platform == 'other':
                    notification(notification_message, title='Covaxon Ontario')
                else:
                    pass

                # Allow user to push enter to book.
                print(
                    "If you would like to book, push Enter/Return within 15 seconds."
                )
                timeout = 15
                rlist, wlist, xlist = select([sys.stdin], [], [], timeout)

                if rlist:
                    # Print message.
                    print("Allowing user to book!")

                    # Sleep to allow user to book.
Пример #21
0
if AUTOUPDATE == 'Yes':
    base_info.wizardUpdate('startup')
else:
    base_info.loga("[Auto Update Wizard] Not Enabled")

base_info.loga("[Notifications] Started")
if ENABLE == 'Yes':
    if not NOTIFY == 'true':
        url = base_info.workingURL(NOTIFICATION)
        if url == True:
            link = base_info.OPEN_URL(NOTIFICATION).replace('\r', '').replace(
                '\t', '')
            id, msg = link.split('|||')
            if int(id) == int(NOTEID):
                if NOTEDISMISS == 'false':
                    notify.notification(msg=msg)
                else:
                    base_info.loga("[Notifications] id[%s] Dismissed" %
                                   int(id))
            elif int(id) > int(NOTEID):
                base_info.loga("[Notifications] id: %s" % str(int(id)))
                base_info.setS('noteid', str(int(id)))
                base_info.setS('notedismiss', 'false')
                notify.notification(msg=msg)
                base_info.loga("[Notifications] Complete")
        else:
            base_info.loga("[Notifications] URL(%s): %s" % (NOTIFICATION, url))
    else:
        base_info.loga("[Notifications] Turned Off")
else:
    base_info.loga("[Notifications] Not Enabled")
Пример #22
0
import requests
import time
from notify import notification

URL = " https://codeforces.com/api/user.status?handle=himansingh241&from=1&count=1"

req = requests.get(url=URL)
data = req.json()
prevSubmissionId = data['result'][0]["id"]

while (True):
    time.sleep(5)
    req = requests.get(url=URL)
    data = req.json()

    verdict = data['result'][0]['verdict']
    problem = data['result'][0]['problem']['index']
    newSubmissionId = data['result'][0]["id"]
    # For debugging purposes
    # s = f"Problem: {problem}, Verdict: {verdict} oldId: {prevSubmissionId} newId: {newSubmissionId}"
    # print(s)
    if (newSubmissionId != prevSubmissionId and verdict != 'TESTING'):
        # print('changed')
        prevSubmissionId = newSubmissionId
        s = f"Problem: {problem}, Verdict: {verdict}"
        # For debugging purposes
        # print(s)
        notification(s, 'Codeforces')

Пример #23
0
def sendnotif(bot):
    msg = (
        'Rien de nouveau\n   tries = {}\n   captcha = {}\n   tunnel = {}\n   sucess = {}'
        .format(bot.tries, bot.captcha, bot.tunnel, bot.success))
    notification(msg, title='GSbot - analyse terminée')
Пример #24
0
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from notify import notification

import time
PATH = '.\chromedriver.exe'

driver = webdriver.Chrome(PATH)
#/html/body/div[1]/div/div[1]/section/div/div[2]/div/div[1]/div[2]/table/tbody/tr[2]/td[3]/center/a
mail = "*****@*****.**"
passw = "testtest"

driver.get("https://vente.tryandjudge.com/dofuskamas.php")
#Norm : /html/body/div[1]/div/div[1]/section/div/div[2]/div/div[1]/div[2]/table/tbody/tr[4]/td[3]/center/a
#VIP:  /html/body/div[1]/div/div[1]/section/div/div[2]/div/div[1]/div[2]/table/tbody/tr[4]/td[3]/center/a

sell = driver.find_element_by_xpath(
    '/html/body/div[1]/div/div[1]/section/div/div[2]/div/div[1]/div[2]/table/tbody/tr[2]/td[3]/center/a'
)
while True:
    if sell.text == 'Cliquez ici pour Vendre':
        sell.click()
        notification('Jri jri rah t7aal', title="bi3 Kama")
        email = driver.find_element_by_xpath('//*[@id="email"]')
        email.send_keys(mail)
        mdp = driver.find_element_by_xpath('//*[@id="mdp"]')
        mdp.send_keys(passw)
        mdp.send_keys(Keys.ENTER)
    else:
        time(5)
        driver.refresh()