Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

having some issue with update ? please help #129

Open
c0d3Astra opened this issue Oct 29, 2023 · 2 comments
Open

having some issue with update ? please help #129

c0d3Astra opened this issue Oct 29, 2023 · 2 comments

Comments

@c0d3Astra
Copy link

[Info] Checking for updates   >Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 1012, in _validate_conn
    conn.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 411, in connect
    self.sock = ssl_wrap_socket(
  File "/usr/lib/python3/dist-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "/usr/lib/python3/dist-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/lib/python3.10/ssl.py", line 1071, in _create
    self.do_handshake()
  File "/usr/lib/python3.10/ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
TimeoutError: _ssl.c:990: The handshake operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/.local/lib/python3.10/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 719, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 385, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 336, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Read timed out. (read timeout=5)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/govind/htb/Villain/./Villain.py", line 1533, in <module>
    main()
  File "/home/govind/htb/Villain/./Villain.py", line 794, in main
    file_data = requests_get(url = raw_url + filename, timeout=(5, 27))
  File "/root/.local/lib/python3.10/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/root/.local/lib/python3.10/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/root/.local/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/root/.local/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/root/.local/lib/python3.10/site-packages/requests/adapters.py", line 532, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Read timed out. (read timeout=5)
@c0d3Astra
Copy link
Author

after commenting out the update line from python code it works fine

	# Check for updates
	# if not args.skip_update:
		
	# 	try:
	# 		local_files_path = current_wd + os.sep
	# 		branch = 'main' 
	# 		url = f'https://api.github.com/repos/t3l3machus/Villain/git/trees/{branch}?recursive=1'
	# 		raw_url = f'https://raw.githubusercontent.com/t3l3machus/Villain/{branch}/'		
	# 		Loading.active = True
	# 		loading_animation = Thread(target = Loading.animate, args = (f'[{INFO}] Checking for updates',), name = 'loading_animation', daemon = True).start()

			
	# 		def get_local_file_hash(filename):
				
	# 			try:
	# 				with open(local_files_path + filename, 'rb') as f:
	# 					data = f.read()
	# 					return md5(data).hexdigest()
						
	# 			except FileNotFoundError:
	# 				return False
		
		
	# 		def update_file(filename, data):
		
	# 			try:
	# 				with open(local_files_path + filename, 'wb') as f:
	# 					f.write(data)
	# 					return True
						
	# 			except:
	# 				return False
		
		
	# 		try:
	# 			response = requests_get(url = url, timeout=(5, 27))
	# 			response.raise_for_status()  # raises stored HTTPError, if one occurred
	# 			res_status_code = response.status_code
				
	# 		#except requests.exceptions.HTTPError as e:
	# 			#print(f'\r[{ERR}] Failed to fetch latest version data: {e}') 
				
	# 		except Exception as e:
	# 			res_status_code = -1
	# 			Loading.stop()
	# 			print(f'\r[{ERR}] Failed to fetch latest version data: {e}') 
		
		
	# 		if res_status_code == 200:
				
	# 			files = [file['path'] for file in response.json()['tree'] if file['type'] == 'blob']
	# 			update_consent = False
				
	# 			for filename in files:
	# 				file_data = requests_get(url = raw_url + filename, timeout=(5, 27))
	# 				latest_signature = md5(file_data.content).hexdigest()
	# 				local_signature = get_local_file_hash(filename)
					
	# 				if not local_signature or (local_signature != latest_signature):
	# 					Loading.stop()
						
	# 					if not update_consent:				
	# 						consent = input(f'\r[{INFO}] Updates detected. Would you like to proceed? [y/n]: ').lower().strip()
		
	# 						if consent in ['y', 'yes']:
	# 							update_consent = True
	# 							Loading.active = True
	# 							loading_animation = Thread(target = Loading.animate, args = (f'[{INFO}] Updating',), name = 'loading_animation', daemon = True).start()
	# 						else:
	# 							break
							
	# 					if update_consent:
	# 						updated = update_file(filename, file_data.content)
							
	# 						if not updated:
	# 							Loading.stop()
	# 							print(f'\r[{ERR}] Error while updating files. Installation may be corrupt. Consider reinstalling Villain.')
	# 							exit(1)
								
	# 			if update_consent:
	# 				Loading.stop()
	# 				print(f'\r[{INFO}] Update completed!')
	# 				os.execv(sys.executable, ['python3'] + sys.argv + ['-q'] + ['-s'])
	# 			else:
	# 				Loading.stop(print_nl = True)	
	# 		else:
	# 			Loading.stop(print_nl = True)
				
	# 	except KeyboardInterrupt:
	# 		Loading.stop(print_nl = True)
	# 		pass

@t3l3machus
Copy link
Owner

Hey, you can use -s to skip update on start-up. I see you experienced ReadTimeout errors, I'll work on the exception handling there, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants