mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-16 07:15:24 +01:00
Handle soft dependency for wxPython properly, addresses #6
This commit is contained in:
parent
057804b93e
commit
4ffcc4b04d
14
GUI.py
14
GUI.py
@ -1,15 +1,17 @@
|
||||
import wx
|
||||
import wx.lib.scrolledpanel as scrolled
|
||||
import wx.richtext as rt
|
||||
import start
|
||||
import threading
|
||||
import time
|
||||
from networking import NetworkManager, PacketSenderManager
|
||||
import thread
|
||||
from threading import Lock
|
||||
|
||||
#pydev error fix
|
||||
wx=wx
|
||||
try:
|
||||
import wx
|
||||
import wx.lib.scrolledpanel as scrolled
|
||||
import wx.richtext as rt
|
||||
#Eclipse pyDev error fix
|
||||
wx=wx
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
connection = None
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import socket
|
||||
import wx
|
||||
import PacketListenerManager
|
||||
import urllib2
|
||||
import urllib
|
||||
@ -14,9 +13,12 @@ from Crypto.Util import asn1
|
||||
from Crypto.PublicKey import RSA
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Cipher import PKCS1_v1_5
|
||||
|
||||
#Eclipse pyDev error fix
|
||||
wx=wx
|
||||
try:
|
||||
import wx
|
||||
#Eclipse pyDev error fix
|
||||
wx=wx
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
EntityID = 0
|
||||
|
||||
|
54
start.py
54
start.py
@ -4,16 +4,16 @@ import getpass
|
||||
import sys
|
||||
from networking import PacketSenderManager, NetworkManager
|
||||
import NoGUIstuff
|
||||
import GUI
|
||||
import time
|
||||
import threading
|
||||
noGoooeees = False
|
||||
wxImportError = False
|
||||
try:
|
||||
import wx
|
||||
import GUI
|
||||
wx = wx
|
||||
except ImportError:
|
||||
print "wxPython not found, falling back to no gui version"
|
||||
noGoooeees = True
|
||||
wxImportError = True
|
||||
|
||||
class MinecraftLoginThread(threading.Thread):
|
||||
|
||||
@ -97,29 +97,33 @@ class KeepConnectionAlive(threading.Thread):
|
||||
self.window.parent.loggedIn = True
|
||||
|
||||
if __name__ == "__main__":
|
||||
noGUI = False
|
||||
if (len(sys.argv) > 1):
|
||||
if(sys.argv[1] == "nogui" or noGoooeees == True):
|
||||
user = raw_input("Enter your username: ")
|
||||
passwd = getpass.getpass("Enter your password: ")
|
||||
derp = NoGUIstuff.loginToMinecraft(user, passwd)
|
||||
if(derp['Response'] == "Incorrect username/password" or derp['Response'] == "Can't connect to minecraft.net" or derp['Response'] == "Account migrated, use e-mail as username."):
|
||||
print derp['Response']
|
||||
sys.exit()
|
||||
sessionid = derp['SessionID']
|
||||
print "Logged in as " + derp['Username'] + "! Your session id is: " + sessionid
|
||||
stuff = raw_input("Enter host and port if any: ")
|
||||
if ':' in stuff:
|
||||
StuffEnteredIntoBox = stuff.split(":")
|
||||
host = StuffEnteredIntoBox[0]
|
||||
port = int(StuffEnteredIntoBox[1])
|
||||
else:
|
||||
host = stuff
|
||||
port = 25565
|
||||
connection = NetworkManager.ServerConnection(None, derp['Username'], passwd, sessionid, host, port)
|
||||
connection.start()
|
||||
while True:
|
||||
chat = raw_input()
|
||||
PacketSenderManager.send03(connection.grabSocket(), chat)
|
||||
if (sys.argv.count("nogui") > 1) :
|
||||
noGUI = True
|
||||
|
||||
if(noGUI or wxImportError):
|
||||
user = raw_input("Enter your username: ")
|
||||
passwd = getpass.getpass("Enter your password: ")
|
||||
derp = NoGUIstuff.loginToMinecraft(user, passwd)
|
||||
if(derp['Response'] == "Incorrect username/password" or derp['Response'] == "Can't connect to minecraft.net" or derp['Response'] == "Account migrated, use e-mail as username."):
|
||||
print derp['Response']
|
||||
sys.exit()
|
||||
sessionid = derp['SessionID']
|
||||
print "Logged in as " + derp['Username'] + "! Your session id is: " + sessionid
|
||||
stuff = raw_input("Enter host and port if any: ")
|
||||
if ':' in stuff:
|
||||
StuffEnteredIntoBox = stuff.split(":")
|
||||
host = StuffEnteredIntoBox[0]
|
||||
port = int(StuffEnteredIntoBox[1])
|
||||
else:
|
||||
host = stuff
|
||||
port = 25565
|
||||
connection = NetworkManager.ServerConnection(None, derp['Username'], passwd, sessionid, host, port)
|
||||
connection.start()
|
||||
while True:
|
||||
chat = raw_input()
|
||||
PacketSenderManager.send03(connection.grabSocket(), chat)
|
||||
else:
|
||||
app = wx.PySimpleApp()
|
||||
Login = GUI.MainFrame(None, -1, "")
|
||||
|
Loading…
Reference in New Issue
Block a user