コード例 #1
0
def request_monitor(site,url,interval,email,price):
    while(1):
        time.sleep(interval)
        if site == "Amazon":
            new_price = scrape_amazon(url)
            print(new_price)
            if(new_price != price):
                send_mail("<senders email>",email,"Price change Alert!","The price of your product has recently changed. Follow this <a href="+url+">link</a>.")
                break
コード例 #2
0
ファイル: trader.py プロジェクト: toomyem/cex-bot
def sell_ghs(amount, price):
    if config.debug_mode:
      msg = "You should sell %f GHS for %0.8f BTC on cex.io" % (amount, price)
      log(msg)
      if config.mail_enabled: notify.send_mail(msg)
      return False
    else:
      msg = "Attempting to sell %f GHS for %0.8f BTC on cex.io" % (amount, price)
      log(msg)
      r = api.place_sell_order(amount, price)
      log(r)
      if config.mail_enabled: notify.send_mail(msg + "\r\n" + str(r))
      return True
コード例 #3
0
ファイル: main.py プロジェクト: stevvv/Price-Tracker
import time
from notify import send_mail
from sites import *

urls = [
    "https://www.amazon.in/Sony-Bravia-Certified-Android-85X8000H/dp/B084T8MD67/ref=sr_1_4?dchild=1&pf_rd_i=1389396031&pf_rd_m=A1K21FY43GMZF8&pf_rd_p=596ea4be-20f6-4a22-bda9-d68047ac4236&pf_rd_r=GW9AJJTJP5V4RWGCK508&pf_rd_s=merchandised-search-14&pf_rd_t=101&qid=1595929056&refinements=p_36%3A7500000-&s=electronics&sr=1-4",
    "https://www.flipkart.com/apple-iphone-se-black-64-gb/p/itm832dd5963a08d?pid=MOBFRFXHCKWDAC4A&lid=LSTMOBFRFXHCKWDAC4AEQROVZ&marketplace=FLIPKART&srno=b_1_1&otracker=hp_rhs_announcement_1_4.rhsAnnouncement.RHS_ANNOUNCEMENT_NG7F2MMCSIA2&fm=neo%2Fmerchandising&iid=f808d16d-4ac1-4f4c-8cfb-5cbe7062eeb7.MOBFRFXHCKWDAC4A.SEARCH&ppt=browse&ppn=browse&ssid=lou82kspq80000001596274471278"
]  # product urls
marked_prices = [
    1000000, 100000
]  # Will notify if the items get below these prices, must pass prices corresponding to urls
items = []

while True:
    for url in urls:
        if "flipkart" in url:
            flipkart(url, items)
        elif "amazon" in url:
            amazon(url, items)

    for i in range(len(items)):
        if items[i]["Price"] <= exp_prices[i]:
            msg = f"Price lowered for {items[i]['Title']} to Rs {items[i]['Price']}.\nGo check it out at {items[i]['Url']}"
            send_mail(msg)
            # print("done")
    time.sleep(6 * 3600)
    items.clear()
コード例 #4
0
ファイル: backup.py プロジェクト: mostafahussein/ops
            if not hasattr(backup_helper, action):
                content.append(">> unsupported action %s\n" % (k,))
                continue
            bak_act = ".".join(("backup_helper", action))
            eval(bak_act)(cfgs, content=content, log=log_fp, dry_run=dry_run)

    except:
        content.append(">> uncatched exception:\n%s\n" %
                       (traceback.format_exc(),))

    if sys.stdout.isatty():
        if content:
            print("".join(content))
        sys.exit(0)
    else:
        log_fp.seek(0, os.SEEK_SET)

    if content:
        content.insert(0, ">>> Error Information\n")
        content.append("\n")
    content.extend(log_fp.readlines())

    hostname = socket.getfqdn()
    subject = " ".join((u'[备份日志]',
                        hostname,
                        cfg_bak.get('config', {}).get('title', '')))
    fromaddr = "root@%s" % (hostname,)
    toaddr = ("*****@*****.**",)
    send_mail(fromaddr, toaddr, subject, "".join(content),
              priority=1)
コード例 #5
0
ファイル: check_raid.py プロジェクト: clan/ops
                result = {v['ok']: re.findall(v['rule'], output, re.I)}
                raid_status.append(result)

        except getopt.error, e:
            raid_info.append(traceback.format_exc())
        except:
            raid_info.append(traceback.format_exc())

        raid_ok = False
        if raid_status:
            raid_ok = True
            for d in raid_status:
                for k, v in d.items():
                    if not (d and all(i == k for i in v)):
                        raid_ok = False
                        break
        if not raid_ok:
            syslog.syslog(syslog.LOG_ERR,
                          "raid array is not in optimal state")
            hostname = socket.getfqdn()
            subject = u'[{{ raid.subject }}] 主机(%s)检测到 RAID 设备故障' % (hostname,)
            fromaddr = "root@%s" % (hostname,)
            toaddr = {{ raid.toaddr }}
            send_mail(fromaddr, toaddr, subject,
                      "\n".join(raid_info), priority=1)
        else:
            syslog.syslog("raid array is in ok state")

    except Exception, e:
        syslog.syslog(syslog.LOG_ERR, "%s" % traceback.format_exc())