Skip to content

Commit

Permalink
error loger added
Browse files Browse the repository at this point in the history
  • Loading branch information
sepandhaghighi committed Jan 5, 2017
1 parent 9ae8e30 commit 960cecf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
18 changes: 12 additions & 6 deletions qpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import urllib.request
import platform
import random

import datetime
meta_input = ""

def print_logo():
Expand Down Expand Up @@ -93,7 +93,7 @@ def find_global_ip():
response = requests.get(ip_finder_api)
return response.text[:-1]
except Exception as e:
print(e)
error_log(e)
return "0.0.0.0"


Expand Down Expand Up @@ -152,7 +152,7 @@ def read_lorem(char=100):
lorem_file.close()
return " ".join(lorem_text.split(" ")[:char])
except Exception as e:
print(e)
error_log(e)
return None


Expand All @@ -173,7 +173,8 @@ def sample_site_download(item_list):
else:
print("Error In Internet Connection!")
print_line(70)
except:
except Exception as e:
error_log(e)
print("Error in downloading sample files check your internet conection")
print_line(70)

Expand All @@ -192,6 +193,10 @@ def logger(status=False, perf_time=None):
file.write("Generation Time: " + str(perf_time) + "\n")
file.close()

def error_log(msg):
file=open("error_log.txt","a")
file.write(str(datetime.datetime.now())+" --> "+str(msg)+"\n")
file.close()

def print_line(number, char="-"):
""" Print a Line
Expand Down Expand Up @@ -724,7 +729,7 @@ def internet(host="8.8.8.8", port=53, timeout=3):
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
return True
except Exception as ex:
print(ex)
error_log(ex)
return False


Expand Down Expand Up @@ -760,7 +765,8 @@ def version_control():
pass
# print("Already Updated!!!")
# print_line(70)
except:
except Exception as e:
error_log(e)
pass


Expand Down
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,19 @@ def main_handler(control_flag=True):
clear_folder(out_dir) # clear all of files in output directory
page_name_update() # update page names
main_handler_2(time_1=start_time) # call part_2 of main_handler
except FileNotFoundError: # error exception in FileNotFound ( When Something Missed)
except FileNotFoundError as e: # error exception in FileNotFound ( When Something Missed)
error_log(e)
logger(False) # Add Failed Run to local logger file
error_handler() # call error_handler
except ValueError:
except ValueError as e:
error_log(e)
print("Bad Input")
logger(False) # Add Failed Run to local logger file
close_files() # Close all of the opne files
enter_to_exit() # get input from user to continue
main_handler() # call part_1 of main_handler , restart from the first
except PermissionError:
except PermissionError as e:
error_log(e)
logger(False) # Add Failed Run to local logger file
print("Files Is Open By Another Program")
close_files() # Close all of the open files
Expand Down

0 comments on commit 960cecf

Please sign in to comment.