-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5618d84
commit a30bc0e
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import sys | ||
import subprocess | ||
import time | ||
import random | ||
import asyncio | ||
import aiohttp | ||
|
||
async def get_ip_info(): | ||
try: | ||
async with aiohttp.ClientSession() as session: | ||
async with session.get("https://ipinfo.io") as response: | ||
data = await response.json() | ||
|
||
ip = data.get('ip') | ||
city = data.get('city') | ||
country = data.get('country') | ||
|
||
print(f"IP: {ip}") | ||
print(f"Location: {city}, {country}") | ||
except Exception as e: | ||
print(f"Error: {e}") | ||
|
||
def run_main(arg=None): | ||
if arg is not None: | ||
subprocess.run([sys.executable, 'hello.py'] + arg) | ||
else: | ||
subprocess.run([sys.executable, 'hello.py']) | ||
|
||
if __name__ == "__main__": | ||
asyncio.run(get_ip_info()) | ||
time.sleep(random.randint(0, 60*2)) # 2 минуты | ||
run_main(["-a", "2"]) # Запускает main.py -a 2 |