Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Moved tellprox into its own package
Browse files Browse the repository at this point in the history
  • Loading branch information
p3tecracknell committed Mar 11, 2013
1 parent d07f1f6 commit e0b56c3
Show file tree
Hide file tree
Showing 25 changed files with 67 additions and 62 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ var
sdist
develop-eggs
.installed.cfg
tdtool.py

# Installer logs
pip-log.txt
Expand Down
7 changes: 7 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
host = 127.0.0.1
port = 8080
dll_path = ""
debug = False
editable = False
client_name = TellProx
client_id = 1
42 changes: 0 additions & 42 deletions tellprox.py

This file was deleted.

Empty file added tellprox/__init__.py
Empty file.
56 changes: 56 additions & 0 deletions tellprox/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python

import sys
if sys.version_info < (2, 5):
print "Sorry, requires Python 2.5, 2.6 or 2.7."
sys.exit(1)

import tellstick_api
import json

from bottle import *
from configobj import ConfigObj
from validate import Validator

# Constants
CONFIG_PATH = 'config.ini'
CONFIG_SPEC = 'configspec.ini'

app = Bottle()

# TODO wrap using virtualenv / py2exe
def main():
config = ConfigObj(CONFIG_PATH, configspec=CONFIG_SPEC)
validator = Validator()
result = config.validate(validator, copy=True)

if result is False:
print "Config file validation failed"
sys.exit(1)

# Write out default values
config.write()

tellstick_api.set_config(config)
app.mount('/json', tellstick_api.app)

debug(config['debug'])
run(app,
host = config['host'],
port = config['port'],
reloader = config['debug'])

@app.route('/')
def server_static():
return static_file('index.html', root='.')

@app.route('/example.html')
def server_static():
return static_file('example.html', root='.')

@app.route('/static/<filepath:path>')
def server_static(filepath='index.html'):
return static_file(filepath, root='./static')

if __name__ == "__main__":
main()
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions tellstick.py → tellprox/tellstick.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ def loadlibrary(self, dllpath):
libraryname = "telldus-core"
else:
libraryname = "TelldusCore"
print "Looking for library: " + libraryname
ret = util.find_library(libraryname)
print "Search: " + ret
if ret == None:
return (None, libraryname)

Expand All @@ -78,6 +80,7 @@ def loadlibrary(self, dllpath):
return None, libraryname
else:
libtelldus = cdll.LoadLibrary(ret)
print "Loading result: " + str(libtelldus)

libtelldus.tdGetName.restype = c_char_p
libtelldus.tdLastSentValue.restype = c_char_p
Expand Down
20 changes: 0 additions & 20 deletions tellstick_api.py → tellprox/tellstick_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
config = None
INIT_LOCK = Lock()

# TODO wrap using virtualenv / py2exe
# TODO use CherryPy for Web UI

app = Bottle()

def set_config(in_config):
Expand All @@ -26,23 +23,6 @@ def initialise_tellstick():
TELLSTICK = TellStick()
TELLSTICK.loadlibrary(config['dll_path'])

@app.route('/test')
def test():
params = {
'oauth_version': "1.0",
'oauth_nonce': oauth.generate_nonce(),
'oauth_timestamp': int(time.time()),
'user': 'joestump',
'photoid': 555555555555
}
#token = oauth.Token(key="tok-test-key", secret="tok-test-secret")
consumer = oauth.Consumer(key="ZUXEVEGA9USTAZEWRETHAQUBUR69U6EF", secret="4e16fe3ecde3f79c2a47a9a8c754556b")
#params['oauth_token'] = token.key
params['oauth_consumer_key'] = consumer.key
url = "http://api.telldus.com"
req = oauth.Request(method="POST", url=url+'/oauth/requestToken', parameters=params)
return req

def get_int(key):
num = request.query.get(key) or ''
try:
Expand Down

0 comments on commit e0b56c3

Please sign in to comment.