Skip to content

Commit

Permalink
Add Python 3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
MA3STR0 committed Apr 23, 2015
1 parent 1bb83b5 commit feb1d30
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Kimsufi/So-you-Start Avaliability Crawler
============================

> Crawler that will notify as soon as OVH servers on Kimsufi/So-you-Start become available for purchase.
> Crawler that will notify you when Kimsufi servers (or So-you-Start, or OVH) become available for purchase.
**TL;DR**

Expand All @@ -17,10 +17,11 @@ About

Dedicated servers on [Kimsufi](http://www.kimsufi.com) and [So you Start](http://www.soyoustart.com) have amazing prices, however they are always out of stock. This crawler will notify you as aoon as servers are available for purchase; it can send emails, show Mac OS notifications, open popup windows, or even trigger sms. Then hurry up, you have around 2 minutes to complete your order :)


Set it up
---------

_Following steps have been tested on Mac and Linux_
**Runs on Linux and Mac with Python 2.7+ or Python 3.4+**

- Clone this repo (`git clone https://github.com/MA3STR0/kimsufi-crawler.git`) or download and unpack archive
- Taking `config.json.example` as a template, create a file `config.json` and correct configuration according to your preferences:
Expand Down
6 changes: 5 additions & 1 deletion crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
from tornado.httpclient import AsyncHTTPClient
from tornado.httpclient import HTTPError
from tornado.gen import coroutine
from urllib import quote
# Python 3 imports
try:
from urllib import quote
except ImportError:
from urllib.parse import quote

logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s')
_logger = logging.getLogger(__name__)
Expand Down
8 changes: 6 additions & 2 deletions notifiers/email_notifier.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Notifier that sends email messages through SMTP"""

import sys
import logging
import smtplib
from email.mime.text import MIMEText
Expand All @@ -18,8 +19,11 @@ def __init__(self, config):
self.use_ssl = config.get('use_ssl', False)
self.fromaddr = config['from_email']
# smtp user may be different from email
self.fromuser = config.get('from_user', self.fromaddr).encode('utf-8')
self.frompwd = config['from_pwd'].encode('utf-8')
self.fromuser = config.get('from_user', self.fromaddr)
self.frompwd = config['from_pwd']
if sys.version_info[0] == 2:
self.fromuser = self.fromuser.encode('utf-8')
self.frompwd = self.frompwd.encode('utf-8')
self.host = config['from_smtp_host']
self.port = config.get('from_smtp_port', 587)
self.toaddr = config['to_email']
Expand Down

0 comments on commit feb1d30

Please sign in to comment.