import asyncio
import subprocess
from typing import List
import aiohttp
async def main():
client = aiohttp.ClientSession()
release_api = "https://launcher.ccpgames.com/eve-online/release/win32/x64/RELEASES"
vercel_api = "https://vedantmgoyal.vercel.app/api/winget-pkgs/versions/CCPGames.EVEOnline"
async with client.get(release_api) as response:
releases_data = await response.text()
versions = get_versions_from_releases_data(releases_data)
print_message("Loaded list of versions for eve-online", "green")
\`\`\`
while True:
try:
async with client.get(vercel_api) as response:
current = await response.json()
break
except Exception:
continue
print_message("Loaded versions in pkgs", "green")
new_versions = set(versions) - set(current['versions'])
print_message(f"PRs will be made for {len(new_versions)} Versions", "green")
await create_pull_requests_for_new_versions(new_versions)
def get_versions_from_releases_data(releases_data: str) -> List[str]:
return list(set(
line.split(' ')[1].split('-')[2]
for line in releases_data.split('\n')
if line.strip()
))
def print_message(message: str, color: str):
colors = {
"green": "\033[92m",
"reset": "\033[0m"
}
print(f"{colors[color]}{message}{colors['reset']}")
async def create_pull_requests_for_new_versions(new_versions: List[str]):
tasks = [create_pull_request(version) for version in new_versions]
await asyncio.gather(*tasks)
async def create_pull_request(version: str):
print_message(f"Making PR for the following version : {version}", "green")
command = f"komac update CCPGames.EVEOnline --urls https://launcher.ccpgames.com/eve-online/release/win32/x64/eve-online-{version}+Setup.exe --version {version} --submit"
subprocess.run(command, shell=True, check=True)
if __name__ == "__main__":
asyncio.run(main())
#๐ pyhton script crashing due to `asyncio`
13 messages ยท Page 1 of 1 (latest)
@wooden mantle
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
errors:
Loaded list of versions for eve-online
Loaded versions in pkgs
Traceback (most recent call last):
File "/media/solomoncyj/solomoncyj/my_things/others/scripts/ccp.py", line 59, in <module>
asyncio.run(main())
File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/media/solomoncyj/solomoncyj/my_things/others/scripts/ccp.py", line 30, in main
new_versions = set(versions) - set(current['versions'])
~~~~~~~^^^^^^^^^^^^
KeyError: 'versions'
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7da3200ee030>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7da31fea49b0>, 1917.13451778)]', '[(<aiohttp.client_proto.ResponseHandler object at 0x7da31fea4ef0>, 1919.96840293)]']
connector: <aiohttp.connector.TCPConnector object at 0x7da31fe81fd0>
This doesn't seem to have anything to do with asyncio. current just doesn't have a versions key.
oh
And current comes from the API you're contacting, so double check that response content.
pyhton script not running in async
new problem: when lanuched, the scrip launches the subprocess in serial insted of palleral
the script will block the spawning of the next subproess untill the current one exits
@zenith stump can you please help me with this part?
I don't know. Sorry.
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.