mirror of https://github.com/sloumdrone/burrow
Merge pull request #15 from sloumdrone/develop
Fixed issue where improper URL did not trigger error, but froze app
This commit is contained in:
commit
f8c189ddbf
|
@ -8,7 +8,7 @@ class connect:
|
||||||
def request(self, resource, host, itemtype, port=70):
|
def request(self, resource, host, itemtype, port=70):
|
||||||
#connects to server and returns list with response type and body
|
#connects to server and returns list with response type and body
|
||||||
socket_conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
socket_conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
socket_conn.settimeout(5.0)
|
socket_conn.settimeout(15.0)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
socket_conn.connect((host, port))
|
socket_conn.connect((host, port))
|
||||||
|
|
21
gui.py
21
gui.py
|
@ -46,7 +46,7 @@ class GUI:
|
||||||
self.MENU_HLB = self.LINK
|
self.MENU_HLB = self.LINK
|
||||||
self.MENU_HLF = self.BAR_BG
|
self.MENU_HLF = self.BAR_BG
|
||||||
|
|
||||||
#create and configure root window
|
#configure root window
|
||||||
self.root = tk.Tk(className='Burrow')
|
self.root = tk.Tk(className='Burrow')
|
||||||
self.root.title('Burrow')
|
self.root.title('Burrow')
|
||||||
sh = self.root.winfo_screenheight()
|
sh = self.root.winfo_screenheight()
|
||||||
|
@ -85,7 +85,6 @@ class GUI:
|
||||||
#menu objects
|
#menu objects
|
||||||
self.context_menu = tk.Menu(self.body, tearoff=0, bg=self.MENU_BG, fg=self.MENU_FG, activebackground=self.MENU_HLB, activeforeground=self.MENU_HLF, activeborderwidth=0)
|
self.context_menu = tk.Menu(self.body, tearoff=0, bg=self.MENU_BG, fg=self.MENU_FG, activebackground=self.MENU_HLB, activeforeground=self.MENU_HLF, activeborderwidth=0)
|
||||||
|
|
||||||
|
|
||||||
self.pack_geometry()
|
self.pack_geometry()
|
||||||
self.add_status_titles()
|
self.add_status_titles()
|
||||||
self.add_event_listeners()
|
self.add_event_listeners()
|
||||||
|
@ -209,7 +208,7 @@ class GUI:
|
||||||
self.root.clipboard_append(text)
|
self.root.clipboard_append(text)
|
||||||
|
|
||||||
|
|
||||||
# ------------Start navigation methods----------------------------
|
# ------------Start navigation methods---------------------------
|
||||||
|
|
||||||
|
|
||||||
def handle_request(self,event=False, url=False, history=True):
|
def handle_request(self,event=False, url=False, history=True):
|
||||||
|
@ -225,22 +224,25 @@ class GUI:
|
||||||
return self.load_home_screen(history)
|
return self.load_home_screen(history)
|
||||||
else:
|
else:
|
||||||
data = {'type': '3', 'body': '3ERROR: Improperly formatted URL\tfalse\tnull.host\t1\n'}
|
data = {'type': '3', 'body': '3ERROR: Improperly formatted URL\tfalse\tnull.host\t1\n'}
|
||||||
return False #error handling goes here
|
# return False
|
||||||
|
elif parsed_url['protocol'] == 'http://':
|
||||||
|
wb.open(url,2,True)
|
||||||
|
self.populate_url_bar(self.history[-1])
|
||||||
|
self.loading_bar.destroy()
|
||||||
|
return False
|
||||||
|
|
||||||
self.populate_url_bar(url)
|
self.populate_url_bar(url)
|
||||||
|
|
||||||
if history:
|
if history:
|
||||||
self.add_to_history(url)
|
self.add_to_history(url)
|
||||||
|
|
||||||
if parsed_url['type'] == '7':
|
if parsed_url and parsed_url['type'] == '7':
|
||||||
self.show_search()
|
self.show_search()
|
||||||
return False # display search
|
return False # display search
|
||||||
elif not parsed_url:
|
elif not parsed_url:
|
||||||
pass
|
data = {'type': '3', 'body': '3ERROR: Improperly formatted URL\tfalse\tnull.host\t1\n'}
|
||||||
else:
|
else:
|
||||||
data = self.execute_address(parsed_url)
|
data = self.execute_address(parsed_url)
|
||||||
if not data:
|
|
||||||
return False #error handling goes here
|
|
||||||
|
|
||||||
self.send_to_screen(data['body'],data['type'])
|
self.send_to_screen(data['body'],data['type'])
|
||||||
|
|
||||||
|
@ -407,7 +409,8 @@ class GUI:
|
||||||
|
|
||||||
tag_name = 'link{}'.format(self.link_count)
|
tag_name = 'link{}'.format(self.link_count)
|
||||||
callback = (lambda event, href=link, tag_name=tag_name: self.gotolink(event, href, tag_name))
|
callback = (lambda event, href=link, tag_name=tag_name: self.gotolink(event, href, tag_name))
|
||||||
favorite = [x for x in self.config['favorites'] if x['url'] == link]
|
# favorite = [x for x in self.config['favorites'] if x['url'] == link]
|
||||||
|
favorite = self.is_favorite(link)
|
||||||
self.site_display.tag_bind(tag_name, "<Button-1>", callback)
|
self.site_display.tag_bind(tag_name, "<Button-1>", callback)
|
||||||
self.site_display.insert(tk.END, types[x['type']], ('type_tag',))
|
self.site_display.insert(tk.END, types[x['type']], ('type_tag',))
|
||||||
self.site_display.insert(tk.END,'\t\t')
|
self.site_display.insert(tk.END,'\t\t')
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
# Handles parsing gopher data:
|
# Handles parsing gopher data:
|
||||||
# URLs, Menus
|
# URLs, Menus
|
||||||
|
|
||||||
class parser:
|
class parser:
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class parser:
|
||||||
resource = '/'
|
resource = '/'
|
||||||
|
|
||||||
if not itemtype:
|
if not itemtype:
|
||||||
return False
|
itemtype = '1'
|
||||||
|
|
||||||
|
|
||||||
self.filetype = itemtype[len(itemtype) - 1] if itemtype else '1'
|
self.filetype = itemtype[len(itemtype) - 1] if itemtype else '1'
|
||||||
|
|
Loading…
Reference in New Issue