refine description strings

This commit is contained in:
Enzo Nunes
2025-02-24 19:34:29 +00:00
parent 4d07495a4e
commit bc8a282e6c
2 changed files with 4 additions and 7 deletions

View File

@@ -9,6 +9,7 @@ LIMIT_COMMITS_30_DAYS = 50
LIMIT_STARS = 200 LIMIT_STARS = 200
LIMIT_NLOC = 100000 LIMIT_NLOC = 100000
MARGIN = 0.1 MARGIN = 0.1
CLONE_DIR = "~/temp/PICable"
def get_stars_info(owner, repo, token): def get_stars_info(owner, repo, token):
@@ -41,14 +42,13 @@ def get_commits_last_30_days(owner, repo, token):
if last_commits_response.status_code != 200: if last_commits_response.status_code != 200:
return -1 return -1
print((page_count - 1) * 30 + len(last_commits_response.json()))
return (page_count - 1) * 30 + len(last_commits_response.json()) return (page_count - 1) * 30 + len(last_commits_response.json())
return len(commits_response.json()) return len(commits_response.json())
def get_lines_of_code(owner, repo): def get_lines_of_code(owner, repo):
repo_url = f"https://github.com/{owner}/{repo}.git" repo_url = f"https://github.com/{owner}/{repo}.git"
clone_dir = os.path.expanduser(f"~/temp/PICable/{repo}") clone_dir = os.path.expanduser(f"{CLONE_DIR}/{repo}")
try: try:
subprocess.run(["git", "clone", repo_url, clone_dir], check=True, stdout=sys.stdout, stderr=sys.stderr) subprocess.run(["git", "clone", repo_url, clone_dir], check=True, stdout=sys.stdout, stderr=sys.stderr)
@@ -63,7 +63,6 @@ def get_lines_of_code(owner, repo):
else: else:
loc = 0 loc = 0
subprocess.run(["rm", "-rf", clone_dir], check=True) subprocess.run(["rm", "-rf", clone_dir], check=True)
print()
return loc return loc

View File

@@ -1,5 +1,4 @@
import asyncio import asyncio
import functools
from sys import argv from sys import argv
import discord import discord
@@ -20,8 +19,7 @@ client = commands.Bot(command_prefix="/", intents=intents)
async def reply_message_async(interaction: discord.Interaction, owner: str, repo: str): async def reply_message_async(interaction: discord.Interaction, owner: str, repo: str):
try: try:
loop = asyncio.get_running_loop() result = await asyncio.to_thread(PICable.PICable, owner, repo, github_token)
result = await loop.run_in_executor(None, functools.partial(PICable.PICable, owner, repo, github_token))
await interaction.followup.send(result) await interaction.followup.send(result)
except Exception as e: except Exception as e:
print(f"Error processing PICable check: {e}") print(f"Error processing PICable check: {e}")
@@ -40,7 +38,7 @@ async def on_ready():
print(f"Failed to sync commands: {e}") print(f"Failed to sync commands: {e}")
@client.tree.command(name="picable", description="Check if a Github repository is eligible for PIC") @client.tree.command(name="picable", description="Check if a Github repository is eligible for PIC.")
@discord.app_commands.describe(owner="The owner of the repository", repository="The name of the repository") @discord.app_commands.describe(owner="The owner of the repository", repository="The name of the repository")
async def picable(interaction: discord.Interaction, owner: str, repository: str): async def picable(interaction: discord.Interaction, owner: str, repository: str):
await interaction.response.defer(ephemeral=False, thinking=True) await interaction.response.defer(ephemeral=False, thinking=True)