2323 raw_input = input
2424
2525
26+ def checksum (issue_template_path ):
27+ """
28+ verifies the checksums of the program before you can create an issue
29+ """
30+
31+ file_skips = [
32+ "__init__" , ".pyc" , ".xml" ,
33+ ".sample" , "HEAD" , "pack" ,
34+ "dev-beta" , "description" , "config" ,
35+ "exclude" , "index" , ".json" ,
36+ ".gitignore" , "LICENSE" , "ISSUE_TEMPLATE" ,
37+ "README" , "CONTRIBUTING" , "hosts.txt" ,
38+ "requirements.txt" , "checksum_link.txt" ,
39+ ".key" , ".id" , ".csv"
40+ ]
41+ current_checksums = []
42+ failed_checks = 0
43+ for root , sub , files in os .walk (lib .settings .CUR_DIR ):
44+ for name in files :
45+ if not any (c in name for c in file_skips ):
46+ path = os .path .join (root , name )
47+ check = hashlib .md5 ()
48+ check .update (open (path ).read ())
49+ check = check .hexdigest ()
50+ current_checksums .append ("{}:{}" .format (path .split ("/" )[- 1 ], check ))
51+ try :
52+ req = requests .get (lib .settings .CHECKSUM_LINK )
53+ real_checksums = str (req .text ).split ("\n " )
54+ for real , current in zip (sorted (real_checksums ), sorted (current_checksums )):
55+ if real != current :
56+ failed_checks += 1
57+ if failed_checks > 0 :
58+ return False
59+ return True
60+ except Exception :
61+ sep = "-" * 35
62+ lib .output .error (
63+ "something went wrong while verifying the checksums of the current application, "
64+ "this could be due to your internet connectivity. Please either try again, or use "
65+ "the following template to create an issue:"
66+ )
67+ print ("{}\n {}\n {}" .format (
68+ sep , open (issue_template_path ).read (), sep
69+ ))
70+ exit (1 )
71+
72+
2673def check_version_number (current_version ):
2774 """
2875 check the version number before creating an issue
@@ -34,7 +81,7 @@ def check_version_number(current_version):
3481 if available_version != current_version :
3582 return False
3683 return True
37- except Exception as e :
84+ except Exception :
3885 return True
3986
4087
@@ -137,6 +184,14 @@ def request_issue_creation(path, arguments, error_message):
137184 request the creation and create the issue
138185 """
139186
187+ if not checksum (path ):
188+ lib .output .error (
189+ "It seems you have changed some of the code in the program. We do not accept issues from edited "
190+ "code as we have no way of reliably testing your issue. We recommend that you only use the version "
191+ "that is available on github, no issue will be created for this problem."
192+ )
193+ exit (1 )
194+
140195 question = raw_input (
141196 "do you want to create an anonymized issue?[y/N]: "
142197 )
0 commit comments