Skip to content

Commit

Permalink
Create start_main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Insomnia731 authored Sep 22, 2024
1 parent 5618d84 commit a30bc0e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions start_main.py
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

0 comments on commit a30bc0e

Please sign in to comment.