A program to check your cusat results

#!/usr/bin/env python
# ----------------------------------------------------------------------
# Cusat Results
# By:Sreekumar K.R
# http://sreekumarkr.wordpress.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# ----------------------------------------------------------------------
# Please report errors and suggestions to sreekumar.dsja@gmail.com
#
import sys
import os
import string
def help():
print "Invalid number of arguments!"
print "-------------------------------------------------------------------"
print "Usage:"
print " -r <regno>"
print " -m <month>"
print " -y <year>"
print " -s <semester>"
print " -supply"
print " Example usage:-\n ./result -r 12080082 -m 6 -y 2008 -s 1"
print " For supplimentary results:-\n ./result -r 12080082 -m 6 -y 2008 -s 1 -supply\n"
print "-------------------------------------------------------------------"


agent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3"
# url to post data
url="http://results.cusat.ac.in/regforms/mrklst-main.php"

# Flags to validate commandline arguments
rok=mok=sok=yok=0

exam = "Regular"
months=['JANUARY','FEBRUARY','MARCH','APRIL','MAY','JUNE','JULY','AUGUST','SEPTEMBER','OCTOBER','NOVEMBER','DECEMBER']
semesters=['','I&II','I&II','III','IV','V','VI','VII','VIII']

# Validating the number of arguments
if(len(sys.argv)<9):
print "Invalid number of arguments!"
help() # print help
exit() # exit from the program

# Processing commandline arguments
for k in range(1,len(sys.argv)):
a = sys.argv[k]
if(a=="-r"):
regno = sys.argv[k+1]
rok=1
elif(a=="-m"):
month = sys.argv[k+1]
mok=1
elif(a=="-s"):
sem = sys.argv[k+1]
sok=1
elif(a=='-y' and (len(sys.argv[k+1])==4)):
year = sys.argv[k+1]
yok=1
elif(a=="-supply"):
exam = "Supplimentary"

else:
continue

#Again validating the arguments
if(not(rok and mok and sok and yok)==1):
help()
exit()
if(not(int(sem)>0 and int(sem)<9)):
print "Invalid number of arguments!"
help()
exit()
if(not(int(month)>0 and int(month)<13)):
print "Invalid Month, Try again"
help()
exit()
# Formating the edate variable from user date
# 'JUNE 2007' - format of edate variable
edate=months[int(month)-1]+" "+year

# Formating semester id
semid=semesters[int(sem)]
print "Please wait........."
# curl command to post data to the server
print exam
curlcommand = "curl --silent -F \"reg=R\" -F \"rno="+regno+"\" -F \"degree=B.Tech\" -F \"sem="+semid+"\" -F \"exam="+exam+"\" -F \"edate="+edate+"\" -A \""+agent+"\" "+url
# Executing curl command
htmltext = os.popen(curlcommand).read()

#Following section process the htmltext(html responce text ) from the server
n=""
start = htmltext.index("Subject")
end = htmltext.index("Disclaimer")
starttag=0
print "----------------------------------------------------------"
#Print the marklist
print "Marklist"
for i in range(start+110,end-1):
if(htmltext[i]=="<"):
starttag=1
elif(htmltext[i]==">"):
starttag=0
if(starttag==0):
n+=htmltext[i]
arr = n.rsplit(">>>>")
for i in range(0,len(arr)):
#print "----------------------------------------------------------"
col = arr[i].rsplit(">>")
row=""
for j in range(0,len(col)):
row+=col[j].ljust(30)+" "
print row
#This section is for debugging purpose, if 'html' is the first argument, then this section will print the whole responce html.
if(len(sys.argv)>1):
if(sys.argv[1]=="html"):
print htmltext



Copy paste the above code in to a file and save it with some name say 'result' without extenstion and then run the program from a terminal by typing
$ chmod +x result
the above code sets permission to the program to run
$ ./result
that will give you a help screen
Example :
$ ./result -r 12080082 -m 6 -y 2008 -s 1

Python!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Operate your s60 Phone from your computer using SeriesS60 Remote!


I was in search of an application that can operate my symbian s60 phone from my computer and at last i found one! SeriesS60 Remote . Its an application that operates your symbian phone from your computer. Using this application you can send / receive  messages , manage contacts, backup files, contacts, messages, browse you phone, send/recive files, sms history, contacts history and much more...

It is easy to setup and manage, this application supports almost all symbian phones and it works fine with Nokia 5233 with ubuntu 10.04(i am using it).

Download Link : http://series60-remote.sourceforge.net/index.php?module=Content&func=view&pid=7

Why Linux (ubuntu) instead of Windows!!

Actually i tried ubuntu about five years ago and  that time i was not aware of using it properly  but i liked it only because its different from Windows. But now i realize its power !!! one of the main reason why i use ubuntu because it allows me to be in full control over my computer. Actually

 

 

 

 

Program your symbian phone from your computer using Python!

Since python is gaining more and more interest among symbian developers and more and more applications are written in Python. So its almost a necessity to have python in your mobile. As i mentioned  in my previous post PyS60 support programming your symbian s60 phones.

But i know its hard to write programs from your phones. PyS60 have an option called Bluetooth console which is an interactive python interpreter running on your phone that communicates with your computer over a bluetooth connection.

Here i will describe, How to setup PyS60 bluetooth console and Linux!

You  will need at least the following tools:

  • hcitool to scan your mobile device

  • sdptool and sdpd daemon to register services like serial port

  • rfcomm to emulate serial port over bluetooth

  • minicom a serial communication program


Then follow these instructions

I hope you have blutooth adapter connected to your computer else plug-in your bluetooth adapter


Then from the terminal type:


$hciconfig reset


Then check that the device is there


$hcitool dev


Then next step is to register a serial port(use channel 1, that may vary)


$sdptool add --channel=1 SP


Now start listing to the the channel


$rfcomm listen rfcomm1 1


Ok, now pickup your phone and make sure that bluetooth is on then go to your python application and  select the bluetooth console. Select your host from the list.


Now it will establish a connection between your phone and computer.


Next you open a new terminal and write the following command


$minicom -o -D /dev/rfcomm1


Now you are in your phones python console.... Enjoy !


Tested with : NOKIA 5233 and Ubuntu 10.04