Beispiel #1
0
    def __init__(self):
        self.lcd_columns = 16
        self.lcd_rows = 2

        self.lcd_buffer = [' ' * self.lcd_columns] * self.lcd_rows

        self.scroll_speed = .5

        self.pushes = []
        self.last_update = False

        self.config = ConfigParser.ConfigParser()
        self.config_paths = ['%s/config' % (os.getcwd())]

        for path in self.config_paths:
            if os.path.exists(path):
                self.config.read(path)

        self.ser = serial.Serial(self.config.get('settings', 'device'))

        logging.basicConfig(format='%(asctime)s %(message)s',
                            datefmt='%m/%d/%Y %I:%M:%S',
                            filename=self.get_setting('log_path'),
                            level=logging.DEBUG)
        self.update_interval = float(self.get_setting('update_interval'))
        self.pause_interval = float(self.get_setting('pause_interval'))
        self.update_time = None
        self.api = pb.PushBullet(self.get_setting('api_key'))

        # autoscroll off
        self.write_cmd([0x52])
        #self.ser.write(b'\xfe\x52')

        # go home
        self.write_cmd([0x48])
        #self.ser.write(b'\xfe\x48')

        # auto newline off
        self.write_cmd([0x44])
        #self.ser.write(b'\xfe\x44')

        # set contrast
        self.write_cmd([0x50, int(self.get_setting('contrast'))])

        self.set_color(int(self.get_setting('red')),
                       int(self.get_setting('green')),
                       int(self.get_setting('blue')))
Beispiel #2
0
    sys.exit(0)


# Monkey patch to delete push on cleanup
def push_delete(self):
    try:
        self.delete()
    except:
        pass


pb.Push.__del__ = push_delete

tests_started = time.time()

api = pb.PushBullet(APIKEY)

devices = api.devices()
contacts = api.contacts()
me = api.me()
chrome = api['Chrome']
device = api.create_device('Test Stream Device')

push = pb.NotePush('lorem ipsum dolor set amet', title='test note')

# Pushing via API object
api.push(push)  # push object to all devices
api.push(push, device)  # push object to device object
api.push(push, device.iden)  # push object to device iden
api.push('lorem ipsum dolor set amet', device.iden,
         title='test note')  # text/args to device iden
Beispiel #3
0
#!/usr/bin/env python
#coding:utf-8

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
import pushybullet as pb
import time
import yaml

conf = yaml.load(open('config.yaml'))

pbapi = pb.PushBullet(conf['api_key'])
devices = pbapi.devices()


#ログアウト処理
def logout():
    driver.find_element_by_id("btnLogout").click()
    driver.close()
    for handle in driver.window_handles:
        driver.switch_to_window(handle)
    driver.close()
    driver.quit()


def jizenyoyaku():
    try:
        #通常速度に戻すお申し込み(1回分予約)を選択
        select = Select(driver.find_element_by_name("selectedRequestStatus"))
        #事前予約申し込み処理
Beispiel #4
0
def main():
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    icon_path = os.path.realpath(os.path.join(os.path.dirname(__file__), "pushbullet.png"))

    icon = Gtk.StatusIcon()
    icon.set_from_file(icon_path)
    icon.set_tooltip_text("PushBullet")
    icon.set_visible(True)
    icon.connect('activate', open_browser)

    Notify.init("PushBullet")

    gtk_thread = Thread(target=Gtk.main)

    try:
        pb = pushybullet.PushBullet(pushybullet.get_apikey_from_config() or sys.argv[1])
    except IndexError:
        from textwrap import dedent
        print(dedent('''
            Either pass your API key as first command line argument,
            or put it into your ~/.config/pushbullet/config.ini file:

            [pushbullet]
            apikey = YOUR_API_KEY_HERE
        '''))

        return

    def pb_watch():
        for ev in pb.stream(use_server_time=True):
            for push in ev.pushes(skip_empty=True):
                if push.type in ('dismissal'):
                    continue

                try:
                    print(str(type(push)), push.json())

                    title = push.get('title') or get_play_app_name(push.get('package_name')) or "PushBullet"
                    body = push.get('body') or push.get('url') or '\n'.join('— %s' % i for i in push.get('items')) or push.get('file_name')

                    if 'icon' in push:
                        loader = GdkPixbuf.PixbufLoader.new_with_type('jpeg')
                        loader.write(push.icon)
                        loader.close()

                        notify = Notify.Notification.new(title, body)
                        notify.set_icon_from_pixbuf(loader.get_pixbuf())

                    else:
                        notify = Notify.Notification.new(title, body, icon_path)

                    notify.show()

                except Exception as e:
                    print(e)

    pb_thread = Thread(target=pb_watch)

    gtk_thread.start()
    pb_thread.start()

    gtk_thread.join()
    pb_thread.terminate()