cannot load auth module
Posted: Mon Mar 18, 2013 10:09 pm
Hi, I've spent the last month trying to set up my pi, get an irc client that works for my needs, and set up proper remote access, and I thought I was finally in the clear once I got everything working, except now I'm running into issues with the following python scripts and was wondering if I could get some help trying to figure out what the issue is. This is a script that provides authorization to connect to a server using a specialized key and passcode, but I keep getting an importerror when I try to load the scripts:
and this is the second part:
If I load the first one it seems to work (I get no error, yet no confirmation), but for the second one I get this:
Traceback (most recent call last):
File: "home/pi/OasizPy/bot.py", line 3, in <module>
import auth
ImportError: No module named auth
Error loading module /home/pi/OasizPy/bot.py
I did a bit of looking, first I tried adding the module_name bit to see if that would fix it but it did not, so I did more searching and apparently this is a library that is supposedly included in python 2.6? I did an apt-get for python and sure enough I already have it, but I also did an apt-get for a module I found called web-auth.py which is apparently linked to auth.py, sure enough there was a package version to install, but it made no difference. What else can I try to get this script to work?
For reference I'm running a standard Pi install, running the recommended Wheezy OS, ssh and vnc through ssh tunnel, nothing really installed as of yet but I made sure everything was up to date. I can't say I know enough about these python scripts to troubleshoot them myself, I am a beginner in programming and only really know basic stuff in java, but I think I have a basic understanding of what I'm looking at (maybe...)
Code: Select all
import socket
import string
import auth
# Variables
_host = "75.126.194.90"
_port = 6667
_channels = "%#TheLobby"
_debug = True
# Misc function(s)
def doSend(str):
s.send("%s\r\n" % (str))
if _debug:
print "-> " + str
# Begin auth/connection
try:
# First we get our authcode
_auth = auth.getAPI("authcode")
if _auth != "ERR":
# Authcode is fine, proceed with server connection
s = socket.socket()
s.connect((_host, _port))
doSend("AUTH OAServPassport I :OASSP000000X1A")
_buffer = ""
while 1:
_buffer = _buffer + s.recv(1024)
temp = string.split(_buffer, "\n")
_buffer = temp.pop()
for line in temp:
line = string.rstrip(line)
param = string.split(line)
if _debug:
print "<- " + line
if param[0][0] == ":":
if param[1] == "005":
# Tell the server we're an IRCx client
doSend("IRCX")
# Join channel(s)
if _channels != "":
doSend("CREATE %s" % (_channels))
else:
if param[0] == "PING":
doSend("PONG")
elif param[0] == "AUTH":
if param[2] == "S":
if param[3] == ":OK":
# Lets send auth code
doSend("AUTH OAServPassport S :%s" % (_auth))
else:
# Lets send challenge response
_cx= auth.getAPI("challenge", param[3][12:])
if _cx != "ERR":
doSend("AUTH OAServPassport S :OASSP000000%s" % (_cx))
else:
print "API error!"
except:
print "Connection error!"
Code: Select all
__module_name__ = "auth.py"
__module_version__ = "1.0"
__module_description__ = "Test"
import urllib
import re
import time
from hashlib import sha1
import hmac
import binascii
import md5
## API DATA
_api_key = "API KEY REMOVED"
_api_pass = "API PASS REMOVED"
## DO NOT EDIT BELOW
_time = time.time()
def makeJSON():
json = "{\"timestamp\":%d}" % (_time)
hashed = hmac.new(_api_pass, json, sha1)
return md5.new(binascii.b2a_base64(hashed.digest())[:-1]).hexdigest()
def getAPI(type, code = ""):
link = "https://www.oasiz.com/api?api_key=%s&access_token=%s×tamp=%d&api_call=" % (_api_key, makeJSON(), _time)
sock = urllib.urlopen("%sircx_%s&query=%s" % (link, type, code))
html = sock.read()
sock.close()
m = re.compile(r'%s": "(.*?)"' % (type)).search(html)
try:
v = m.group(1)
except:
v = "ERR"
return v
Traceback (most recent call last):
File: "home/pi/OasizPy/bot.py", line 3, in <module>
import auth
ImportError: No module named auth
Error loading module /home/pi/OasizPy/bot.py
I did a bit of looking, first I tried adding the module_name bit to see if that would fix it but it did not, so I did more searching and apparently this is a library that is supposedly included in python 2.6? I did an apt-get for python and sure enough I already have it, but I also did an apt-get for a module I found called web-auth.py which is apparently linked to auth.py, sure enough there was a package version to install, but it made no difference. What else can I try to get this script to work?
For reference I'm running a standard Pi install, running the recommended Wheezy OS, ssh and vnc through ssh tunnel, nothing really installed as of yet but I made sure everything was up to date. I can't say I know enough about these python scripts to troubleshoot them myself, I am a beginner in programming and only really know basic stuff in java, but I think I have a basic understanding of what I'm looking at (maybe...)