--- trunk/gcoder/client/COder2.py 2006/08/25 21:56:23 76
+++ trunk/gcoder/client/COder2.py 2006/09/10 11:03:38 77
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- python -*-
-# Version 0.1.0.1
-# Time-stamp: <2006-01-28 22:10:52 Deepak Thukral, Vinay Sekhri>
+# Version 0.1.0.77
+# Time-stamp: <2006-09-10 22:20:12 Deepak Thukral, Vinay Sekhri>
from Tkinter import *
from socket import *
@@ -17,7 +17,7 @@
__support__ = 'iapainATgmail.com, vinay.sekhriATgmail.com'
__www__ = 'http://gcoder.sf.net/'
__version__ = '0.1'
-__built__ = '0.1 (beta RC1) Developer Version'
+__built__ = '0.1.0.77 (Beta 1) Developer Version'
__date__ = '2006/03/05'
__shortcutkeys__ = 'Compile: F5, Find: Ctrl+F, Find Again: F3, GoTo:
Ctrl+G, Save Code: Ctrl+S, Test Code: Ctrl+E, Submit Code: Ctrl+U,
\nUndo: Ctrl+Z, Redo: Ctrl+Y, Select All: Ctrl+A'
@@ -97,51 +97,36 @@
act = 1
quit_v = 1
root = Tix.Tk()
+ root.protocol("WM_DELETE_WINDOW", close)
root.title(s_node['AppName'])
root.geometry(s_node['AppSize'])
- root.bind('<Destroy>',close)
+ #root.bind('<Destroy>',close)
root.withdraw()
w = COder (root)
init()
root.mainloop()
def init():
- global o_c, o_o, app_name,server_addr
- global cl , port ,prob, comp #
- server_addr = s_node['ServerIP']
- if server_addr == '127.0.0.1':
- server_addr = gethostbyname(gethostname())
+ global o_c, o_o
app_name = s_node['AppName']
prob = '0'
o_c = w.tix36_text
o_o = w.tix35_text
w.self_load()
- cl = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
- try:
- cl.connect((server_addr,int(s_node['ServerPort'])))
- except:
+ if(check_code == 1):
alert.greeting('Couldnt find Coding Server [@'+ server_addr
+'], make sure your Config.xml points to a valid server.')
root.destroy()
return
- port = cl.recv(128)
- cl.close()
- port = int(port,10)
- print(port)
- cl = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
- try:
- cl.connect((server_addr,port))
- except:
+
+ if(check_code == 2):
alert.greeting('Couldnt connect to '+ sever_addr +':'+ port
+', you have no running instance.')
root.destroy()
load_conf()
login_user()
if w:
w.loadprob("2")
-
-
- '''load_sample()'''
-# Parses all information about COder appliacation from
xml_data/config.xml in dictionary 's_node'
+# Parses all information about COder appliacation from
xml_data/config.xml in dictionary 's_node' and connect to server
def load_settings():
import xml.dom.minidom as mini
global s_node, s_xml #setting node
@@ -157,6 +142,29 @@
except:
s_node[e.localName] = ''
+ #server connection before loading Tk
+ global app_name, server_addr, check_code
+ global cl , port ,prob, comp
+ check_code = 0
+ server_addr = s_node['ServerIP']
+ if server_addr == '127.0.0.1':
+ server_addr = gethostbyname(gethostname())
+ cl = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
+ try:
+ cl.connect((server_addr,int(s_node['ServerPort'])))
+ except:
+ check_code = 1
+ return
+ port = cl.recv(128)
+ cl.close()
+ port = int(port,10)
+ print(port)
+ cl = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
+ try:
+ cl.connect((server_addr,port))
+ except:
+ check_code = 2
+
def lock_instance():
if s_xml:
@@ -215,19 +223,23 @@
submit_file = node['submit']'''
print node
-def close(self):
- global w
- unlock_instance()
- cl.close()
- #ser.close()
- #ser.shutdown('SHUT_RDWR')
- root.quit()
- '''if w != None :
+def close(self=None):
+ if tkMessageBox.askokcancel("Quit", "Do you really wish to quit?"):
+ global w
+ unlock_instance()
+ cl.close()
+ #ser.close()
+ #ser.shutdown('SHUT_RDWR')
+ root.destroy()
+ '''if w != None :
con = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
con.connect((socket.gethostbyname(socket.gethostname()),7070))
con.send('close\n<end>\n')
con.close()'''
- w = None
+ w = None
+ return
+ else:
+ return
def read_textbox(o):
# Note how one can read all of the characters from a text box. The
@@ -859,7 +871,7 @@
import time
#time.sleep(2)
d.top.destroy()
- alert.greeting("You'r successfully authenticated, press okay
to enter in arena.")
+ alert.greeting("You've successfully authenticated, press okay
to enter in arena.")
root.deiconify()
else:
alert.greeting("Authentication failed, Please check your
username/password.")
--
Deepak Thukral
http://www.niecdelhi.com/~deepak/
cse...@cs...
|