mirror of
				https://github.com/mail-in-a-box/mailinabox.git
				synced 2025-10-31 19:00:54 +00:00 
			
		
		
		
	Fixed TRY300 (try-consider-else): Consider moving this statement to an else block
				
					
				
			This commit is contained in:
		
							parent
							
								
									9d9e900ca2
								
							
						
					
					
						commit
						77a7a29322
					
				| @ -380,11 +380,12 @@ def dns_set_record(qname, rtype="A"): | |||||||
| 
 | 
 | ||||||
| 		if set_custom_dns_record(qname, rtype, value, action, env): | 		if set_custom_dns_record(qname, rtype, value, action, env): | ||||||
| 			return do_dns_update(env) or "Something isn't right." | 			return do_dns_update(env) or "Something isn't right." | ||||||
| 		return "OK" |  | ||||||
| 
 | 
 | ||||||
| 	except ValueError as e: | 	except ValueError as e: | ||||||
| 		return (str(e), 400) | 		return (str(e), 400) | ||||||
| 
 | 
 | ||||||
|  | 	return "OK" | ||||||
|  | 
 | ||||||
| @app.route('/dns/dump') | @app.route('/dns/dump') | ||||||
| @authorized_personnel_only | @authorized_personnel_only | ||||||
| def dns_get_dump(): | def dns_get_dump(): | ||||||
|  | |||||||
| @ -105,12 +105,12 @@ def check_service(i, service, env): | |||||||
| 		s.settimeout(1) | 		s.settimeout(1) | ||||||
| 		try: | 		try: | ||||||
| 			s.connect((ip, service["port"])) | 			s.connect((ip, service["port"])) | ||||||
| 			return True |  | ||||||
| 		except OSError: | 		except OSError: | ||||||
| 			# timed out or some other odd error | 			# timed out or some other odd error | ||||||
| 			return False | 			return False | ||||||
| 		finally: | 		finally: | ||||||
| 			s.close() | 			s.close() | ||||||
|  | 		return True | ||||||
| 
 | 
 | ||||||
| 	if service["public"]: | 	if service["public"]: | ||||||
| 		# Service should be publicly accessible. | 		# Service should be publicly accessible. | ||||||
|  | |||||||
| @ -39,9 +39,9 @@ def load_settings(env): | |||||||
|         with open(fn, encoding="utf-8") as f: |         with open(fn, encoding="utf-8") as f: | ||||||
|             config = rtyaml.load(f) |             config = rtyaml.load(f) | ||||||
|         if not isinstance(config, dict): raise ValueError # caught below |         if not isinstance(config, dict): raise ValueError # caught below | ||||||
|         return config |  | ||||||
|     except: |     except: | ||||||
|         return { } |         return { } | ||||||
|  |     return config | ||||||
| 
 | 
 | ||||||
| # UTILITIES | # UTILITIES | ||||||
| 
 | 
 | ||||||
| @ -172,10 +172,11 @@ def wait_for_service(port, public, env, timeout): | |||||||
| 		s.settimeout(timeout/3) | 		s.settimeout(timeout/3) | ||||||
| 		try: | 		try: | ||||||
| 			s.connect(("127.0.0.1" if not public else env['PUBLIC_IP'], port)) | 			s.connect(("127.0.0.1" if not public else env['PUBLIC_IP'], port)) | ||||||
| 			return True |  | ||||||
| 		except OSError: | 		except OSError: | ||||||
| 			if time.perf_counter() > start+timeout: | 			if time.perf_counter() > start+timeout: | ||||||
| 				return False | 				return False | ||||||
|  | 		else: | ||||||
|  | 			return True | ||||||
| 		time.sleep(min(timeout/4, 1)) | 		time.sleep(min(timeout/4, 1)) | ||||||
| 
 | 
 | ||||||
| def get_ssh_port(): | def get_ssh_port(): | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user