Beispiel #1
0
def job():

    config = None

    with open ("config.json") as file:
        config = json.load(file)

    for market in config.get("markets"):

        if market["active"] is False:
            continue

        symbol = market["name"]
        max_price = market["max"]
        min_price = market["min"]
        ticker = binance_client.get_symbol_ticker(symbol=symbol)
        price = float(ticker.get("price"))

        if price > max_price or price < min_price:
            Notifier.notify(message="{} is currently ${}".format(symbol, price),
                            title='Crypto Alert!',
                            appIcon='https://i.imgur.com/yqsHQIL.png',
                            open='https://www.binance.com/en/trade/BTC_USDT')

            Notifier.remove(os.getpid())
            Notifier.list(os.getpid())
Beispiel #2
0
def notify(
    title="Python notification",
    message: str = "Your program has completed",
    duration: float = 10.,
    sound: str = None
):
    if sys.platform != "darwin":
        # pynotifier is windows+linux
        from pynotifier import Notification

        Notification(
            title=title,
            description=message,
            icon_path=python_icon,
            duration=duration,
            urgency=Notification.URGENCY_CRITICAL
        ).send()
    else:
        from pync import Notifier

        Notifier.notify(message, title=title)
        Notifier.remove(os.getpid())
        Notifier.list(os.getpid())

    if sound is not None:
        if sound == "random":
            soundfile = get_random_soundfile()
        else:
            soundfile = get_soundfile(sound)

        playsound(soundfile)
Beispiel #3
0
 def notify_mountainlion(n):
     notify_normal(n)
     return
     group_id = '%d-%s' % (os.getpid(),n.id)
     text = n.text
     if len(_notify_tree):
         temp_tree = [x.text for x in _notify_tree] + [text]
         text = '\n'.join(['%s%s' % ('  '*i,temp_tree[i]) for i in xrange(len(temp_tree))])
         group_id = '%d-%s' % (os.getpid(),_notify_tree[0].id)
         Notifier.remove(group_id)
     Notifier.notify(text,title='Jarvis',group=group_id)
Beispiel #4
0
def send_macos_notification(unread_count, message_senders, title, arg_dict):
    notification_group_id = "notifier"

    Notifier.notify(
        message="BaseMessage" + ("s" if (len(message_senders) > 1 and unread_count > 1) else "") + " from: " +
                ", ".join(message_senders),  # content of notification
        title=title + ": " + str(unread_count) + " unread message" + (
            "s" if unread_count > 1 else ""),  # notification title
        group=notification_group_id,  # ID used to group notification with previous notifications
        **arg_dict
    )

    Notifier.remove(notification_group_id)
Beispiel #5
0
def print_all_notifications(title, message):
    Notifier.remove('SMS_ALERTS')
    print "Notification received: {0}: {1}".format(title, message)
    
    number = title.strip('Number::')
    number = re.sub('\+1','',number)
    number = re.sub('\+27','',number)
    try:
        contact = get_contact_name(number)
        print 'This is the Contact: %s' % (contact)
        Notifier.notify(message.strip('Msg::'), title='TXT From: %s' % contact, group='SMS_ALERTS', execute="/Users/adewinter/acode/rmac/rmac/test.py")
        save_received(number, message)
            
    except Exception as e:
        print e
def news(rssFeedUrl):
	count = 0

	parseFeedUrl = urlopen(rssFeedUrl)
	page = parseFeedUrl.read()
	parseFeedUrl.close()

	soupPage = BeautifulSoup(page, "xml")
	newsList = soupPage.find_all("item")
	
	for news in newsList:
		time.sleep(5) #Pauses system for 5 milliseconds
		if(count < 5): #Notifies you about the first 5 items on RSS Feed
			
			Notifier.notify('Tesla News', title = news.title.text, 
                    appIcon='/Users/joshuawelsh/Desktop/PythonScripts/TeslaNewsApp/App/newsIcon.png', open=news.link.text)
			Notifier.remove(os.getpid())
			
		count = count + 1
Beispiel #7
0
def updateChecker(oldfile, newfile):
    for i in repoNames:
        if oldfile[i] == newfile[i]:
            Notifier.notify("Repository Updated", title=i)
            Notifier.remove(os.getpid())
            Notifier.list(os.getpid())
            with open("repos.json", "w") as r:  #Erases content in file
                r.close()
            with open("repos.json", "w") as n:
                n.write("{\n")
                for i in newfile:
                    n.write("\"" + i +
                            "\": ")  # Re writes file with updated repos
                    n.write("\"" + newfile[i] + "\" ")
                n.write("\n}")
                n.close()
                exit()
            break
        else:
            print("No updates have occurred")
from datetime import datetime
import googlemaps
import json
gmaps = googlemaps.Client(key=GOOGLEMAPS_API_KEY)

# Request directions via public transit
now = datetime.now()
directions_result = gmaps.directions(FROM_ADDRESS,
                                     TO_ADDRESS,
                                     mode="driving",
                                     departure_time=now)

time_to_home = directions_result[0]['legs'][0]['duration_in_traffic']['text']

# Display notification on your mac with a link to google maps with prepopulated TO and FROM fields.
from pync import Notifier
import os

Notifier.notify(time_to_home, title='Traffic Update', open=GOOGLE_MAPS_LINK)
Notifier.remove(os.getpid())

Notifier.list(os.getpid())

# Send a text message
from subprocess import call
call([
    "osascript", "sendMessage.applescript", TARGET_PHONE_NUMBER,
    "Hello, current time from Millennium park to Skydeck is: " + time_to_home
])
def searchCar_uCar():
    # 有车查询
    postdata = {"citycode": "440402", "cityCode": "440402", "sign": uCarUserId}
    header = {'URCARSPID': '00100'}
    r = requests.post(
        "http://www.ur-car.com.cn:8082/urcar/station/queryAllStation",
        data=postdata,
        headers=header)

    uc = uCarQueryAllModel()
    uc.__dict__ = r.json()

    isHave = False
    canRentalAddressList = []
    nowTime = time.strftime("%l:%M:%S", time.localtime())
    print(nowTime)

    for content in uc.content:
        canRentalNum = content['canRentalNum']
        stationName = content['stationName']
        if canRentalNum != 0:
            isHave = True
            # 当前可租车辆的可用里程查询
            stationId = content['id']

            postdata_li = {"stationId": stationId, "cityCode": "undefined"}
            header_li = {'URCARSPID': '00100'}
            r_li = requests.post(
                "http://www.ur-car.com.cn:8082/urcar/vehicle/queryVehicleByStationId",
                data=postdata_li,
                headers=header_li)

            carResponse_li = r_li.json()
            contentList_li = carResponse_li['content']

            mileAgeList = []
            dianLiangList = []
            for content_li in contentList_li:
                vehicleType = content_li['vehicleType']
                mileAge = vehicleType['mileAge']  # 当前可续航里程数
                mileAgeList.append(mileAge)
                activityHandlerParamList = content_li[
                    'activityHandlerParamList']
                for activityHandlerParam in activityHandlerParamList:
                    maxMilage = activityHandlerParam['maxMilage']  # 最大续航
                dianLiang = mileAge / maxMilage * 100
                dianLiang = mileAge / 160 * 100  # 感觉接口的maxMilage=300是固定假数据暂时设定160
                dianLiangList.append(dianLiang)

            mileStr = ''
            for index in range(len(mileAgeList)):
                if index == 0:
                    mileStr = '%d' % (mileAgeList[index])
                else:
                    mileStr = mileStr + ',%d' % (mileAgeList[index])

            dianLiangStr = ''
            for index in range(len(dianLiangList)):
                if index == 0:
                    dianLiangStr = '%d%%' % (dianLiangList[index])
                else:
                    dianLiangStr = dianLiangStr + ',%d%%' % (
                        dianLiangList[index])

            canRentalAddressList.append(
                '【%s】数量:%d,续航:%s,电量:%s' %
                (stationName, canRentalNum, mileStr, dianLiangStr))

    if isHave == True:
        print('***uCar有车啦***')
        notifyStr = ''
        for str in canRentalAddressList:
            notifyStr = notifyStr + str

        # Mac os 系统通知
        Notifier.notify(notifyStr, title='uCar有车啦 ' + nowTime, group='aaa')
        Notifier.remove('aaa')
        print(canRentalAddressList)

    else:

        print('uCar还没有车')
def searchCar_yiBuCar():
    latitude = '22.254915'
    longitude = '113.55859'

    # 有车查询
    urlJsonParam = {
        'instance': '5000',
        'latitude': latitude,
        'longitude': longitude,
        'cityCode': '440400'
    }
    jsonUrlData = {
        'method': 'queryParkList',
        'phone': '',
        'cId': yiBuUserId,
        'version': '1.7.3',
        'memberId': '',
        'type': 'member',
        'param': urlJsonParam
    }
    urlJsonStr = json.dumps(jsonUrlData)
    r = requests.get('https://interface.ibgoing.com/services/i/e/' +
                     urlJsonStr)
    uc = yiBuQueryAllModel()
    uc.__dict__ = r.json()

    isHave = False
    canRentalAddressList = []
    nowTime = time.strftime("%l:%M:%S", time.localtime())
    print(nowTime)

    for content in uc.result:
        canRentalNum = content['freeCarNum']
        stationName = content['address']

        cityCodeResult = content['cityCode']

        if cityCodeResult != cityCode:
            continue

        if int(canRentalNum) != 0:
            isHave = True
            # 当前可租车辆的可用里程查询
            stationId = content['parkId']

            urlJsonParam_li = {'size': '30', 'parkId': stationId, 'page': '1'}
            jsonUrlData_li = {
                'method': 'queryCarList',
                'phone': '',
                'cId': yiBuUserId,
                'version': '1.7.3',
                'memberId': '',
                'type': 'member',
                'param': urlJsonParam_li
            }
            urlJsonStr_li = json.dumps(jsonUrlData_li)
            r_li = requests.get('https://interface.ibgoing.com/services/i/e/' +
                                urlJsonStr_li)

            carResponse_li = r_li.json()
            contentList_li = carResponse_li['result']

            mileAgeList = []
            dianLiangList = []
            for content_li in contentList_li:
                mileAge = content_li['mileage']  # 当前可续航里程数
                mileAgeList.append(mileAge)
                dianLiangList.append(content_li['batteryResidual'])  # 剩余电量

            mileStr = ''
            for index in range(len(mileAgeList)):
                if index == 0:
                    mileStr = '%s' % (mileAgeList[index])
                else:
                    mileStr = mileStr + ',%s' % (mileAgeList[index])

            dianLiangStr = ''
            for index in range(len(dianLiangList)):
                if index == 0:
                    dianLiangStr = '%s%%' % (dianLiangList[index])
                else:
                    dianLiangStr = dianLiangStr + ',%s%%' % (
                        dianLiangList[index])

            canRentalAddressList.append(
                '【%s】数量:%s,续航:%s,电量:%s' %
                (stationName, canRentalNum, mileStr, dianLiangStr))

    if isHave == True:
        print('***宜步有车啦***')
        notifyStr = ''
        for str in canRentalAddressList:
            notifyStr = notifyStr + str

        # Mac os 系统通知
        Notifier.notify(notifyStr, title='宜步有车啦 ' + nowTime, group='ccc')
        Notifier.remove('ccc')
        print(canRentalAddressList)

    else:

        print('宜步还没有车')
def searchCar_warmCar():
    latitude = '22.254915'
    longitude = '113.55859'

    # 有车查询
    postdata = {
        "cityId": "200",
        "comCode": "GZPH001",
        "lang": "zh",
        'latitude': latitude,
        'longitude': longitude
    }
    header = {}
    r = requests.post("https://app.feezu.cn/car/findCompanyStation",
                      data=postdata,
                      headers=header)

    uc = warmCarQueryAllModel()
    uc.__dict__ = r.json()

    isHave = False
    canRentalAddressList = []
    nowTime = time.strftime("%l:%M:%S", time.localtime())
    print(nowTime)

    for content in uc.data:
        canRentalNum = content['avaliableCarNum']
        stationName = content['stationName']
        if canRentalNum != 0:
            isHave = True
            # 当前可租车辆的可用里程查询
            stationId = content['stationId']

            postdata_li = {
                "stationId": stationId,
                "businessType": "3",
                'comCode': 'GZPH001',
                'lang': 'zh',
                'latitude': latitude,
                'longitude': longitude
            }
            header_li = {}
            r_li = requests.post(
                "https://app.feezu.cn/car/findCarsByStationId",
                data=postdata_li,
                headers=header_li)

            carResponse_li = r_li.json()
            contentList_li = carResponse_li['data']

            mileAgeList = []
            dianLiangList = []
            for content_li in contentList_li:
                mileAge = content_li['mileLeft']  # 当前可续航里程数
                mileAgeList.append(mileAge)
                dianLiangList.append(content_li['fuelPercentage'])  # 剩余电量

            mileStr = ''
            for index in range(len(mileAgeList)):
                if index == 0:
                    mileStr = '%s' % (mileAgeList[index])
                else:
                    mileStr = mileStr + ',%s' % (mileAgeList[index])

            dianLiangStr = ''
            for index in range(len(dianLiangList)):
                if index == 0:
                    dianLiangStr = '%s' % (dianLiangList[index])
                else:
                    dianLiangStr = dianLiangStr + ',%s' % (
                        dianLiangList[index])

            canRentalAddressList.append(
                '【%s】数量:%d,续航:%s,电量:%s' %
                (stationName, canRentalNum, mileStr, dianLiangStr))

    if isHave == True:
        print('***WarmCar有车啦***')
        notifyStr = ''
        for str in canRentalAddressList:
            notifyStr = notifyStr + str

        # Mac os 系统通知
        Notifier.notify(notifyStr, title='WarmCar有车啦 ' + nowTime, group='bbb')
        Notifier.remove('bbb')
        print(canRentalAddressList)

    else:

        print('WarmCar还没有车')
Beispiel #12
0
            continue
        yield line

if __name__ == "__main__":
    home = expanduser("~")
    #eveLogPathPost = join('Documents', 'EVE', 'logs', 'Gamelogs')
    eveLogPathPost = join('Library', 'Preferences', 'EVE Online Preferences', 'p_drive', 'My Documents', 'EVE')
    eveLogs = join(home, eveLogPathPost)
    files = sorted([f for f in listdir(eveLogs)])
    newest = files[-1]
    rdyLog = join(eveLogs, newest)
    logfile = open(rdyLog)
    loglines = watchFile(logfile)
    for line in loglines:
        try:
            message = line
            Notifier.notify(message)
        except (KeyboardInterrupt, SystemExit):
            logfile.close()
            Notifier.remove(os.getpid())
            exit()
            raise
        except:
            logfile.close()
            Notifier.remove(os.getpid())
            exit()
        else:
            pass
logfile.close()
Notifier.remove(os.getpid())
Beispiel #13
0
def kill_notification():
    Notifier.remove(os.getpid())
    exit()
Beispiel #14
0
def searchCar():

    latitude = '22.254915'
    longitude = '113.55859'

    # 有车查询
    postdata = {
        "cityId": "200",
        "comCode": "GZPH001",
        "lang": "zh",
        'latitude': latitude,
        'longitude': longitude
    }
    header = {}
    r = requests.post("https://app.feezu.cn/car/findCompanyStation",
                      data=postdata,
                      headers=header)

    uc = warmCarQueryAllModel()
    uc.__dict__ = r.json()

    isHave = False
    orderNameList = [
        '安驰修车行',
        '力航',
        '旅游',
    ]
    canRentalAddressList = []
    nowTime = time.strftime("%l:%M:%S", time.localtime())
    print(nowTime)

    for content in uc.data:
        OrderNameData = content['stationName']

        isHaveOrderNameInList = False  #是否含有查询的站点
        for orderName in orderNameList:
            if orderName in OrderNameData:  #模糊对比,包含有字符就行
                isHaveOrderNameInList = True

        if isHaveOrderNameInList == True:
            print('找到站点:' + OrderNameData)
        else:
            continue

        canRentalNum = content['avaliableCarNum']
        stationName = content['stationName']
        if canRentalNum != 0:
            isHave = True
            # 当前可租车辆的可用里程查询
            stationId = content['stationId']

            postdata_li = {
                "stationId": stationId,
                "businessType": "3",
                'comCode': 'GZPH001',
                'lang': 'zh',
                'latitude': latitude,
                'longitude': longitude
            }
            header_li = {}
            r_li = requests.post(
                "https://app.feezu.cn/car/findCarsByStationId",
                data=postdata_li,
                headers=header_li)

            carResponse_li = r_li.json()
            contentList_li = carResponse_li['data']

            mileAgeList = []
            dianLiangList = []
            for content_li in contentList_li:
                mileAge = content_li['mileLeft']  # 当前可续航里程数
                mileAgeList.append(mileAge)
                dianLiangList.append(content_li['fuelPercentage'])  # 剩余电量

            mileStr = ''
            for index in range(len(mileAgeList)):
                if index == 0:
                    mileStr = '%s' % (mileAgeList[index])
                else:
                    mileStr = mileStr + ',%s' % (mileAgeList[index])

            dianLiangStr = ''
            for index in range(len(dianLiangList)):
                if index == 0:
                    dianLiangStr = '%s' % (dianLiangList[index])
                else:
                    dianLiangStr = dianLiangStr + ',%s' % (
                        dianLiangList[index])

            canRentalAddressList.append(
                '【%s】数量:%d,续航:%s,电量:%s' %
                (stationName, canRentalNum, mileStr, dianLiangStr))

    if isHave == True:
        print('***WarmCar有车啦***')
        notifyStr = ''
        for str in canRentalAddressList:
            notifyStr = notifyStr + str

        # Mac os 系统通知
        icon_file = cur_file_dir() + "/icon_searchCar.ico"
        Notifier.notify(notifyStr,
                        title='WarmCar有车啦 ' + nowTime,
                        group='bbb',
                        closeLabel='关闭',
                        actions='一键下单(暂不开放)',
                        appIcon=icon_file)
        Notifier.remove('bbb')
        print(canRentalAddressList)

    for orderName_2 in orderNameList:
        isStationHaveCar = False
        for str in canRentalAddressList:
            if orderName_2 in str:  # 模糊对比,包含有字符就行
                isStationHaveCar = True

        if isStationHaveCar == False:
            print('WarmCar还没有车:' + orderName_2)
Beispiel #15
0
def exit_handler():
    print("Exiting pyWater")
    Notifier.remove(os.getpid())
            # Random notes :)

    # if __name__ == "__main__":
    #     pync.notify('Hello World',
    #                 title="Omsai",
    #                 subtitle="hello this is developer king pro",

    #                 icon='pngfuel.com-19.png',
    #                 )

# pync.notify('Hello World', title='Python')
# pync.notify('Hello World', group=os.getpid())
# pync.notify('Hello World', activate='com.apple.Safari')
# pync.notify('Hello World', open='http://github.com/')
# pync.notify('Hello World', execute='say "OMG"')
'''
Notifier.remove(os.getpid())

Notifier.list(os.getpid())
'''
# d = input("enter the number\n")
# # print(type
# #       (d))
# numm = int(d)
# # print(type(numm))
# one = (numm * (numm + 1))
# print(one/2)
# a = str(0)
# print(a)

# # today = datetime.datetime.now().strftime("%d-%m-%y")