i have a WORKING (yes, WORKING) gcn client written in python (python is a cross-platform interperated language. its basically everything java wants to be and more, including the byte-compiled ability - www.python.org )

it connects to the CURRENT gcn.cemetech.net just fine, check out this screenie



NOTE: the hostname, host pass, calc name, calc pass, calc ID are all specifieable in the gcn.connect and gcn.disconnect functions, however, i pre-declared mine in the gcn.py file so that you can't see my passwords Wink

currently you can only connect and disconnect, but hey, its a start Laughing

Oh, and incase you were wondering, there IS a wxwidgets python port, so i can still have a fancy cross-platform GUI on top of this Very Happy
yay, and I have python. Where does one get gcn client?
you mean the one i just wrote? i'll just post it here, since its not that long...


Code:
import urllib
import httplib
import md5

#fill these out with your own info, or specify when calling connect or disconnect
usrname = ''
calcname = ''
usr_pass = ''
calc_pass = ''
calcid = ''
#don't edit below!

def connect(usrname = usrname, usr_pass = usr_pass, calcname = calcname, calc_pass = calc_pass, calcid = calcid, debug = 0):
   headers = {'Content-type': 'application/x-www-form-urlencoded', 'Host': 'gcn.cemetech.net', 'IPAddr': '172.16.1.33', 'User-Agent': usrname}
   params = urllib.urlencode({'query': 'ADD%%' + usrname + '%%' + md5.md5(usr_pass).hexdigest() + '%%' + calcid + '%%1', 'username': calcname, 'pwdmd5': md5.md5(calc_pass).hexdigest(), 'IPAddr: ': '172.16.1.33'})
   conn = httplib.HTTPConnection("gcn.cemetech.net")
   conn.request("POST", "/index.php", params, headers)
   response = conn.getresponse()
   if (debug):
      print headers
      print params
      print response.status, response.reason   
   return response.read()

def disconnect(usrname = usrname, calcid = calcid, calcname = calcname, calc_pass = calc_pass, debug = 0):
   headers = {'Content-type': 'application/x-www-form-urlencoded', 'Host': 'gcn.cemetech.net', 'IPAddr': '172.16.1.33', 'User-Agent': usrname}
   params = urllib.urlencode({'query': 'REMOVE%%' + usrname + '%%' + calcid + '%%', 'username': calcname, 'pwdmd5': md5.md5(calc_pass).hexdigest(), 'IPAddr: ': '172.16.1.33'})
   conn = httplib.HTTPConnection("gcn.cemetech.net")
   conn.request("POST", "/index.php", params, headers)
   response = conn.getresponse()
   if (debug):
      print headers
      print params
      print response.status, response.reason   
   return response.read()


I saved mine in a file called gcn.py, then i simply launch python from the same dir as the file, and type "import gcn". Then its either "gcn.connect()" or "gcn.disconnect()" (you could also copy/paste the entire thing into the interperater, however, then instead of it being gcn.connect(), its simply connect())

Note: you can either specify the vars in the file, or change them "on-the-fly" by doing gcn.usrname = "whatever", etc... (usrname is also called "host name"), i strongly suggest you pre-store the values to the proper vars, as then your function calls are short, and you don't have to worry about specifying the params in the wrong order Wink
Hey, that's pretty impressive! I suppose this is a subtle hint to get going on the new server configuration? Smile
nice, I like python. You can turn it into a native application Smile
It looks pretty intuitive (time to make it 22 langs...) Very Happy
KermMartian wrote:
Hey, that's pretty impressive! I suppose this is a subtle hint to get going on the new server configuration? Smile


MAKE THE CALC SIDE ALREADY!!!!

gCn can continue to use to current implementation for now, cause without the calc side there's no point to any of this Rolling Eyes
But I can't do that without 5.5 being released. Smile
hurry it up, also, the client worked
Yup, worked for me too.
won't be able to test it till I get home.....are we switching from C++ to Python now? Smile
elfprince13 wrote:
won't be able to test it till I get home.....are we switching from C++ to Python now? Smile


we CAN, if you want. I was just trying to learn python, and noticed the httplib mentioned headers and data as optional parameters, so i figured i'd give it and shot and see if it worked - this was the only way i could really "test" it, per se Laughing

--there is a python USB module, which does see the ti-84+se via directlink, but i don't know if it can send/receive from it OK or not (as i have nothing to test this with, lol) : http://pyusb.berlios.de/

--Or if you write the USB interface in C, it can then be modulized and loaded into python, so you could still interact with the calcs via C if you wanted

Oh, and I've re-wrote it as a class and split up part of the functions - should allow it to be more flexible if it gets used in the future.... It ALSO now has a "setup" (run automatically for first time) and then stores the settings into a settings.cfg file (currently it just saves it in the dir you launched python from). Next time you use the gcn2 class, it will pull up all your old settings automatically. IF you need to change the settings, just call obj.setup() where obj is the instance of the gcn2 class you are using (look at the screenshot for what i mean, as connect and disconnect are called the same way as setup)

screenshot first, then code:




Code:
import urllib
import httplib
import md5
import pickle
   
class gcn2:
   def setup(self):
      hostname = str(raw_input('Host Name: '))
      hostpass = md5.md5(str(raw_input('Host Pass: '))).hexdigest()
      calcname = str(raw_input('Calc Name: '))
      calcpass = md5.md5(str(raw_input('Calc Pass: '))).hexdigest()
      calcid   = str(raw_input('Calc ID: '  ))
      config = {'Host Name': hostname, 'Host Pass': hostpass, 'Calc Name': calcname, 'Calc Pass': calcpass, 'Calc ID': calcid}
      cfile = open('settings.cfg', 'w')
      pickle.dump(config, cfile)
      cfile.close()
      self.conf = config
   
   def connect(self):
      params = urllib.urlencode({'query': 'ADD%%' + self.conf.get('Host Name') + '%%' + self.conf.get('Host Pass') + '%%' + self.conf.get('Calc ID') + '%%1', 'username': self.conf.get('Calc Name'), 'pwdmd5': self.conf.get('Calc Pass'), 'IPAddr: ': '172.16.1.33'})
      data = self.dorequest(params)
      return data
   
   def disconnect(self):
      params = urllib.urlencode({'query': 'REMOVE%%' + self.conf.get('Host Name') + '%%' + self.conf.get('Calc ID') + '%%', 'username': self.conf.get('Calc Name'), 'pwdmd5': self.conf.get('Calc Pass'), 'IPAddr: ': '172.16.1.33'})
      data = self.dorequest(params)
      return data
   
   def dorequest(self, params):
      headers = {'Content-type': 'application/x-www-form-urlencoded', 'Host': 'gcn.cemetech.net', 'IPAddr': '172.16.1.33', 'User-Agent': self.conf.get('Host Name')}
      conn = httplib.HTTPConnection("gcn.cemetech.net")
      conn.request("POST", "/index.php", params, headers)
      response = conn.getresponse()
      return response.read()
   def __init__(self):
      try:
         cfile = open('settings.cfg')
         self.conf = pickle.load(cfile)
      except IOError:
         self.setup()
Nope, still using C++, need it for the tilp libs.
KermMartian wrote:
Nope, still using C++, need it for the tilp libs.


actually TILP uses C, and THAT could be made into a python module ;D
I meant that you can include C libs in C++. Smile
true, C can be used in C++ - but C can also be used in python, so whether or not python or C++ is used or not is irrelevant at this point, as h.a.cking the tilp libs to do what we need it to do is probably the biggest obstical right now, but it'll be hard to test if its working right or not without something on the calc to TEST it with Laughing
Kllrnohj wrote:
true, C can be used in C++ - but C can also be used in python, so whether or not python or C++ is used or not is irrelevant at this point, as h.a.cking the tilp libs to do what we need it to do is probably the biggest obstical right now, but it'll be hard to test if its working right or not without something on the calc to TEST it with Laughing

Actually there's no need to censor them, they allow people to use the libs...
lol, you misunderstand, the term h.a.cking is used in this case to mean "modified", which is how it is often used in linux land. The TILP libs have more stuff than we need (which will need to be trimmed out), along with GUI bindings that also have to be cut out and/or replaced. Just like the libs will need to be streamlined down into one library for gCn, as it will be communicating directly with the calc gcn (at least, as far as i understand anyway), so all the TI-OS routines won't be needed, nor will alot of the other stuff.

Get what I mean now?
Ohhh, now I get it. Smile
switched it over to a GUI - now requires wxPython (wxPython is a set of wxWidgets bindings for python - http://www.wxpython.org/ )

screenshots:





Code:

http://www.kllrnohj.com/cemetech/gCn2/gcngui.py

(its now too long to just post here, 200+ lines)

EDIT: Ooops, looks like i forgot to change the title bar text Laughing
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page 1, 2, 3, 4, 5, 6, 7, 8, 9  Next
» View previous topic :: View next topic  
Page 1 of 9
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement