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+ print "\n " .join (current_checksums );exit (1 )
52+ try :
53+ req = requests .get (lib .settings .CHECKSUM_LINK )
54+ real_checksums = str (req .text ).split ("\n " )
55+ for real , current in zip (sorted (real_checksums ), sorted (current_checksums )):
56+ if real != current :
57+ failed_checks += 1
58+ if failed_checks > 0 :
59+ return False
60+ return True
61+ except Exception :
62+ sep = "-" * 35
63+ lib .output .error (
64+ "something went wrong while verifying the checksums of the current application, "
65+ "this could be due to your internet connectivity. Please either try again, or use "
66+ "the following template to create an issue:"
67+ )
68+ print ("{}\n {}\n {}" .format (
69+ sep , open (issue_template_path ).read (), sep
70+ ))
71+ return False
72+
73+
2674def check_version_number (current_version ):
2775 """
2876 check the version number before creating an issue
@@ -34,7 +82,7 @@ def check_version_number(current_version):
3482 if available_version != current_version :
3583 return False
3684 return True
37- except Exception as e :
85+ except Exception :
3886 return True
3987
4088
@@ -137,6 +185,14 @@ def request_issue_creation(path, arguments, error_message):
137185 request the creation and create the issue
138186 """
139187
188+ if not checksum (path ):
189+ lib .output .error (
190+ "it seems you have changed some of the code in the program. We do not accept issues from edited "
191+ "code as we have no way of reliability testing your issue. We recommend that you only use the version "
192+ "that is available on github, no issue will be created for this problem, DO NOT REPORT IT"
193+ )
194+ exit (1 )
195+
140196 question = raw_input (
141197 "do you want to create an anonymized issue?[y/N]: "
142198 )
0 commit comments