From 94b703439580ef57d368aa2132fe607f6acff2b9 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 12:42:02 +0100 Subject: [PATCH 01/29] Create utils.py --- miraheze/salt/utils.py | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 miraheze/salt/utils.py diff --git a/miraheze/salt/utils.py b/miraheze/salt/utils.py new file mode 100644 index 0000000..dc5a082 --- /dev/null +++ b/miraheze/salt/utils.py @@ -0,0 +1,51 @@ + + +class DbClusterMap(TypedDict): + c1: str + c2: str + c3: str + c4: str + + +# Define the mapping of db clusters to db names +db_clusters: DbClusterMap = { + 'c1': 'db151', + 'c2': 'db161', + 'c3': 'db171', + 'c4': 'db181', +} + + +def generate_salt_command(cluster: str, command: str) -> str: + return f'salt-ssh -E "{cluster}" cmd.run "{command}"' + + + +def execute_salt_command(salt_command: str, shell: bool = True, stdout: Optional[int] = None, text: Optional[bool] = None) -> Optional[subprocess.CompletedProcess]: + response = input(f'EXECUTE (type c(continue), s(kip), a(bort): {salt_command}') + if response in ['c', 'continue']: + try: + return subprocess.run(salt_command, shell=shell, stdout=stdout, text=text, check=True) + except subprocess.CalledProcessError as e: + print(f"Command '{salt_command}' failed with return code {e.returncode}") + except Exception as e: + print(f"An error occurred: {e}") + return None + if response in ['s', 'skip']: + return None + sys.exit(1) # noqa: R503 + + +def get_db_cluster(wiki: str) -> str: + db_query = f'SELECT wiki_dbcluster FROM mhglobal.cw_wikis WHERE wiki_dbname = \\"{wiki}\\"' + command = generate_salt_command('db171', f"sudo -i mysql --skip-column-names -e '{db_query}'") + result = execute_salt_command(salt_command=command, stdout=subprocess.PIPE, text=True) + if result: + cluster_name = result.stdout.strip() + cluster_data = cluster_name.split('\n') + cluster_data_b = cluster_data[1].split(' ') + print(cluster_data_b) + cluster_name = cluster_data_b[4] + + return db_clusters[cluster_name] # type: ignore[literal-required] + raise KeyboardInterrupt('Impossible to skip. Aborted.') From aeb9d4eb27d4d43aa1c64f3ef268ee3968d81012 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 12:44:03 +0100 Subject: [PATCH 02/29] Update utils.py --- miraheze/salt/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/miraheze/salt/utils.py b/miraheze/salt/utils.py index dc5a082..7934bb1 100644 --- a/miraheze/salt/utils.py +++ b/miraheze/salt/utils.py @@ -1,4 +1,7 @@ - +import subprocess +import sys +import os +from typing import Optional, TypedDict class DbClusterMap(TypedDict): c1: str @@ -29,7 +32,7 @@ def execute_salt_command(salt_command: str, shell: bool = True, stdout: Optional except subprocess.CalledProcessError as e: print(f"Command '{salt_command}' failed with return code {e.returncode}") except Exception as e: - print(f"An error occurred: {e}") + print(f'An error occurred: {e}') return None if response in ['s', 'skip']: return None From 52d5c9bdfde7641a385f6dc45971e6144e22a0d3 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 12:46:21 +0100 Subject: [PATCH 03/29] Update utils.py --- miraheze/salt/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/miraheze/salt/utils.py b/miraheze/salt/utils.py index 7934bb1..6e6bc4b 100644 --- a/miraheze/salt/utils.py +++ b/miraheze/salt/utils.py @@ -1,8 +1,8 @@ import subprocess import sys -import os from typing import Optional, TypedDict + class DbClusterMap(TypedDict): c1: str c2: str @@ -23,7 +23,6 @@ def generate_salt_command(cluster: str, command: str) -> str: return f'salt-ssh -E "{cluster}" cmd.run "{command}"' - def execute_salt_command(salt_command: str, shell: bool = True, stdout: Optional[int] = None, text: Optional[bool] = None) -> Optional[subprocess.CompletedProcess]: response = input(f'EXECUTE (type c(continue), s(kip), a(bort): {salt_command}') if response in ['c', 'continue']: From f98d71be3aed44e4a0fa4992fc6a0ece01d1f5d4 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 12:46:39 +0100 Subject: [PATCH 04/29] Update setup.py --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 0be6231..09efc26 100644 --- a/setup.py +++ b/setup.py @@ -19,8 +19,8 @@ name='Miraheze_PyUtils', version=VERSION, description='Python Utilities for Miraheze', - long_description=readme, # + '\n\n' + history, - long_description_content_type='text/markdown', # This is important! + long_description=readme, # + '\n\n' + history, + long_description_content_type='text/markdown', # This is important! author='RhinosF1', author_email='rhinosf1@wikitide.org', url='https://github.com/FOSSBots/MirahezeBots', From 5f3f30f1927ec5c22d4133638c1e90931655206f Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 12:49:58 +0100 Subject: [PATCH 05/29] Update utils.py --- miraheze/salt/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/miraheze/salt/utils.py b/miraheze/salt/utils.py index 6e6bc4b..45170b3 100644 --- a/miraheze/salt/utils.py +++ b/miraheze/salt/utils.py @@ -39,9 +39,9 @@ def execute_salt_command(salt_command: str, shell: bool = True, stdout: Optional def get_db_cluster(wiki: str) -> str: - db_query = f'SELECT wiki_dbcluster FROM mhglobal.cw_wikis WHERE wiki_dbname = \\"{wiki}\\"' + db_query = f"SELECT wiki_dbcluster FROM mhglobal.cw_wikis WHERE wiki_dbname = '{wiki}'" command = generate_salt_command('db171', f"sudo -i mysql --skip-column-names -e '{db_query}'") - result = execute_salt_command(salt_command=command, stdout=subprocess.PIPE, text=True) + result = execute_salt_command(salt_command=commandd, stdout=subprocess.PIPE, text=True) if result: cluster_name = result.stdout.strip() cluster_data = cluster_name.split('\n') From 45bf879afb8b29a4cf61d3b5f16aab74abb91da7 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 12:50:19 +0100 Subject: [PATCH 06/29] Update utils.py --- miraheze/salt/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miraheze/salt/utils.py b/miraheze/salt/utils.py index 45170b3..9236d96 100644 --- a/miraheze/salt/utils.py +++ b/miraheze/salt/utils.py @@ -41,7 +41,7 @@ def execute_salt_command(salt_command: str, shell: bool = True, stdout: Optional def get_db_cluster(wiki: str) -> str: db_query = f"SELECT wiki_dbcluster FROM mhglobal.cw_wikis WHERE wiki_dbname = '{wiki}'" command = generate_salt_command('db171', f"sudo -i mysql --skip-column-names -e '{db_query}'") - result = execute_salt_command(salt_command=commandd, stdout=subprocess.PIPE, text=True) + result = execute_salt_command(salt_command=command, stdout=subprocess.PIPE, text=True) if result: cluster_name = result.stdout.strip() cluster_data = cluster_name.split('\n') From 7dee776f1ad3080cae1c91cb38154beaa4ee4d03 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 12:52:35 +0100 Subject: [PATCH 07/29] Update python.yml --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 4513857..438c7af 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -24,7 +24,7 @@ jobs: - name: Run tests run: | flake8 --ignore=E501,W503,SFS301,T003,PT009 - coverage run --branch -m pytest tests + #coverage run --branch -m pytest tests mypy --ignore-missing-imports --disallow-untyped-defs notify-irc: From 533a108d252d8500774367aa388088f063b4d535 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 12:53:39 +0100 Subject: [PATCH 08/29] Update python.yml --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 438c7af..3f093b7 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -25,7 +25,7 @@ jobs: run: | flake8 --ignore=E501,W503,SFS301,T003,PT009 #coverage run --branch -m pytest tests - mypy --ignore-missing-imports --disallow-untyped-defs + mypy miraheze --ignore-missing-imports --disallow-untyped-defs notify-irc: needs: build From aa3ebc9b6ef298d10d57c4317ae8490f08cd4780 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 12:55:37 +0100 Subject: [PATCH 09/29] Create partial-reset-wiki.py --- miraheze/salt/mwcli/partial-reset-wiki.py | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 miraheze/salt/mwcli/partial-reset-wiki.py diff --git a/miraheze/salt/mwcli/partial-reset-wiki.py b/miraheze/salt/mwcli/partial-reset-wiki.py new file mode 100644 index 0000000..23f62a0 --- /dev/null +++ b/miraheze/salt/mwcli/partial-reset-wiki.py @@ -0,0 +1,30 @@ +import argparse +from miraheze.salt.utils import * + +def reset_wiki(wiki: str) -> None: + # Step 1: Get the db cluster for the wiki + + try: + wiki_cluster = get_db_cluster(wiki) + except (KeyError, IndexError): + print(f'Error: Unable to determine the db cluster for {wiki}') + sys.exit(1) + + # Step 2: Execute deleteWiki.php + execute_salt_command(salt_command=generate_salt_command('mwtask181', f'mwscript extensions/CreateWiki/deleteWiki.php loginwiki --deletewiki {wiki} --delete {os.getlogin()}')) + + # Step 3: Backup and drop database + execute_salt_command(salt_command=generate_salt_command(wiki_cluster, f"sudo -i mysqldump {wiki} > {wiki}.sql'")) + execute_salt_command(salt_command=generate_salt_command(wiki_cluster, f"sudo -i mysql -e 'DROP DATABASE {wiki}'")) + + +def main() -> None: + parser = argparse.ArgumentParser(description='Executes the commands needed to reset wikis') + parser.add_argument('--wiki', required=True, help='Old wiki database name') + + args = parser.parse_args() + reset_wiki(args.wiki) + + +if __name__ == '__main__': + main() From 95502dd6db8fa7c854c2e11c486f52bbb926a806 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 12:56:18 +0100 Subject: [PATCH 10/29] Create rename-wiki.py --- miraheze/salt/mwcli/rename-wiki.py | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 miraheze/salt/mwcli/rename-wiki.py diff --git a/miraheze/salt/mwcli/rename-wiki.py b/miraheze/salt/mwcli/rename-wiki.py new file mode 100644 index 0000000..e22e74c --- /dev/null +++ b/miraheze/salt/mwcli/rename-wiki.py @@ -0,0 +1,33 @@ +import argparse +from miraheze.salt.utils import * + +def rename_wiki(oldwiki_db: str, newwiki_db: str) -> None: + # Step 1: Get the db cluster for the old wiki dbname + oldwiki_cluster = get_db_cluster(oldwiki_db) + + try: + oldwiki_cluster = get_db_cluster(oldwiki_db) + except KeyError: + print(f'Error: Unable to determine the db cluster for {oldwiki_db}') + sys.exit(1) + + # Step 2: Execute SQL commands for rename + execute_salt_command(salt_command=generate_salt_command(oldwiki_cluster, f'mysqldump {oldwiki_db} > oldwikidb.sql')) + execute_salt_command(salt_command=generate_salt_command(oldwiki_cluster, f"mysql -e 'CREATE DATABASE {newwiki_db}'")) + execute_salt_command(salt_command=generate_salt_command(oldwiki_cluster, f"mysql -e 'USE {newwiki_db}; SOURCE /home/$user/oldwikidb.sql'")) + + # Step 3: Execute MediaWiki rename script + execute_salt_command(salt_command=generate_salt_command('mwtask181', f'sudo -u www-data php /srv/mediawiki/1.41/extensions/CreateWiki/maintenance/renameWiki.php --wiki=loginwiki --rename {oldwiki_db} {newwiki_db} $user')) + + +def main() -> None: + parser = argparse.ArgumentParser(description='Executes the commands needed to rename wikis') + parser.add_argument('--oldwiki', required=True, help='Old wiki database name') + parser.add_argument('--newwiki', required=True, help='New wiki database name') + + args = parser.parse_args() + rename_wiki(args.oldwiki, args.newwiki) + + +if __name__ == '__main__': + main() From c16d1805a9a77a0fdcb10617a2d38cd01bf60b28 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 12:58:03 +0100 Subject: [PATCH 11/29] Create __init__.py --- miraheze/salt/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 miraheze/salt/__init__.py diff --git a/miraheze/salt/__init__.py b/miraheze/salt/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/miraheze/salt/__init__.py @@ -0,0 +1 @@ + From 4182a23279c090b7f9458fc6141d9f6958bb400d Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 12:58:15 +0100 Subject: [PATCH 12/29] Create __init__.py --- miraheze/salt/mwcli/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 miraheze/salt/mwcli/__init__.py diff --git a/miraheze/salt/mwcli/__init__.py b/miraheze/salt/mwcli/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/miraheze/salt/mwcli/__init__.py @@ -0,0 +1 @@ + From f44967ec0ebcf36b80390742a13305c54696d9ea Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 12:58:28 +0100 Subject: [PATCH 13/29] Create __init__.py --- miraheze/swift/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 miraheze/swift/__init__.py diff --git a/miraheze/swift/__init__.py b/miraheze/swift/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/miraheze/swift/__init__.py @@ -0,0 +1 @@ + From a0c1b5ff5b113aa4f9345bc236cd7c408676d714 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:00:22 +0100 Subject: [PATCH 14/29] Update python.yml --- .github/workflows/python.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 3f093b7..15f95e9 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -21,6 +21,8 @@ jobs: sudo apt-get install -y libgnutls28-dev pip install -U pip pip install -r .github/pythonchecks.txt + pyproject-build --wheel --outdir dist . + find dist -name "*.whl" | xargs pip3 install - name: Run tests run: | flake8 --ignore=E501,W503,SFS301,T003,PT009 From 0c09c2ed74bd2cea2b6f7088abab053e337a9f25 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:02:07 +0100 Subject: [PATCH 15/29] Update pythonchecks.txt --- .github/pythonchecks.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/pythonchecks.txt b/.github/pythonchecks.txt index 42db7e1..f1bdbf2 100644 --- a/.github/pythonchecks.txt +++ b/.github/pythonchecks.txt @@ -21,6 +21,7 @@ pytest-xdist==3.3.1 flake8-noqa==1.3.2 coverage==7.3.2 setuptools==68.2.2; python_version == '3.12' +build==1.2.1 ## ACTUAL requests==2.28.1; python_version == '3.11' requests==2.31.0; python_version == '3.12' From 8d2a3b3e8ee4f89bb3c4c0ef38f0e8f46a72d134 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:03:29 +0100 Subject: [PATCH 16/29] Update setup.py --- setup.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/setup.py b/setup.py index 09efc26..9bba3c6 100644 --- a/setup.py +++ b/setup.py @@ -6,14 +6,6 @@ with open('README.md') as readme_file: readme = readme_file.read() -# with open('CHANGELOG.md') as history_file: -# history = history_file.read() -with open('requirements.txt') as requirements_file: - requirements = list(requirements_file.readlines()) - -# with open('dev-requirements.txt') as dev_requirements_file: -# dev_requirements = list(dev_requirements_file.readlines()) - setup( name='Miraheze_PyUtils', From 287a4d6f305b53f1e56442e482a6448861e3b202 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:05:20 +0100 Subject: [PATCH 17/29] Update setup.py --- setup.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 9bba3c6..1c2c26d 100644 --- a/setup.py +++ b/setup.py @@ -11,15 +11,13 @@ name='Miraheze_PyUtils', version=VERSION, description='Python Utilities for Miraheze', - long_description=readme, # + '\n\n' + history, + long_description=readme long_description_content_type='text/markdown', # This is important! author='RhinosF1', author_email='rhinosf1@wikitide.org', - url='https://github.com/FOSSBots/MirahezeBots', + url='https://github.com/miraheze/python-functions', packages=find_packages('.'), include_package_data=True, - install_requires=requirements, - # tests_require=dev_requirements, test_suite='tests', license='GPL3', ) From 7a45b29100ed44d6612ae14ca05614aab36b0acc Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:06:07 +0100 Subject: [PATCH 18/29] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1c2c26d..abf2905 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ name='Miraheze_PyUtils', version=VERSION, description='Python Utilities for Miraheze', - long_description=readme + long_description=readme, long_description_content_type='text/markdown', # This is important! author='RhinosF1', author_email='rhinosf1@wikitide.org', From b84b28e5bad82d1e627c3aea712ec283373aa427 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:20:03 +0100 Subject: [PATCH 19/29] Update python.yml --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 15f95e9..3b73aa1 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -25,7 +25,7 @@ jobs: find dist -name "*.whl" | xargs pip3 install - name: Run tests run: | - flake8 --ignore=E501,W503,SFS301,T003,PT009 + flake8 --exclude=build/* --ignore=E501,W503,SFS301,T003,PT009 #coverage run --branch -m pytest tests mypy miraheze --ignore-missing-imports --disallow-untyped-defs From 2ebef732ec0545bd309ed31beff261b49b8709bf Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:22:32 +0100 Subject: [PATCH 20/29] Update partial-reset-wiki.py --- miraheze/salt/mwcli/partial-reset-wiki.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miraheze/salt/mwcli/partial-reset-wiki.py b/miraheze/salt/mwcli/partial-reset-wiki.py index 23f62a0..d79b946 100644 --- a/miraheze/salt/mwcli/partial-reset-wiki.py +++ b/miraheze/salt/mwcli/partial-reset-wiki.py @@ -1,5 +1,5 @@ import argparse -from miraheze.salt.utils import * +from miraheze.salt.utils import generate_salt_command,execute_salt_command,get_db_cluster def reset_wiki(wiki: str) -> None: # Step 1: Get the db cluster for the wiki From 7ae8f47dc54d529c939c9e429117df83be4762b1 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:22:42 +0100 Subject: [PATCH 21/29] Update rename-wiki.py --- miraheze/salt/mwcli/rename-wiki.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miraheze/salt/mwcli/rename-wiki.py b/miraheze/salt/mwcli/rename-wiki.py index e22e74c..32ce633 100644 --- a/miraheze/salt/mwcli/rename-wiki.py +++ b/miraheze/salt/mwcli/rename-wiki.py @@ -1,5 +1,5 @@ import argparse -from miraheze.salt.utils import * +from miraheze.salt.utils import generate_salt_command,execute_salt_command,get_db_cluster def rename_wiki(oldwiki_db: str, newwiki_db: str) -> None: # Step 1: Get the db cluster for the old wiki dbname From 39f7802b71e662141781a67d547dcbaf6a35ae5e Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:24:42 +0100 Subject: [PATCH 22/29] Update __init__.py From f199185f4d9be71abb8436933622cff5005d089e Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:25:57 +0100 Subject: [PATCH 23/29] Update partial-reset-wiki.py --- miraheze/salt/mwcli/partial-reset-wiki.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/miraheze/salt/mwcli/partial-reset-wiki.py b/miraheze/salt/mwcli/partial-reset-wiki.py index d79b946..46d05a1 100644 --- a/miraheze/salt/mwcli/partial-reset-wiki.py +++ b/miraheze/salt/mwcli/partial-reset-wiki.py @@ -1,5 +1,8 @@ import argparse -from miraheze.salt.utils import generate_salt_command,execute_salt_command,get_db_cluster +import sys +import os +from miraheze.salt.utils import generate_salt_command, execute_salt_command, get_db_cluster + def reset_wiki(wiki: str) -> None: # Step 1: Get the db cluster for the wiki From 882a13e60e1d718a62cedf97e5225f7e7b26ae82 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:26:34 +0100 Subject: [PATCH 24/29] Update rename-wiki.py --- miraheze/salt/mwcli/rename-wiki.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/miraheze/salt/mwcli/rename-wiki.py b/miraheze/salt/mwcli/rename-wiki.py index 32ce633..dbcf1ee 100644 --- a/miraheze/salt/mwcli/rename-wiki.py +++ b/miraheze/salt/mwcli/rename-wiki.py @@ -1,5 +1,7 @@ import argparse -from miraheze.salt.utils import generate_salt_command,execute_salt_command,get_db_cluster +import sys +from miraheze.salt.utils import generate_salt_command, execute_salt_command, get_db_cluster + def rename_wiki(oldwiki_db: str, newwiki_db: str) -> None: # Step 1: Get the db cluster for the old wiki dbname From 99e7bd26c6f7afe733cc59953da81d5284bd7fd0 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:26:52 +0100 Subject: [PATCH 25/29] Update python.yml --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 3b73aa1..e69106b 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -25,7 +25,7 @@ jobs: find dist -name "*.whl" | xargs pip3 install - name: Run tests run: | - flake8 --exclude=build/* --ignore=E501,W503,SFS301,T003,PT009 + flake8 --exclude=*/__init__.py,dist/*,build/* --ignore=E501,W503,SFS301,T003,PT009 #coverage run --branch -m pytest tests mypy miraheze --ignore-missing-imports --disallow-untyped-defs From 971f85bcd2e5aa6a0b478aa3442bd5a788668c12 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:30:56 +0100 Subject: [PATCH 26/29] Update setup.cfg --- setup.cfg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.cfg b/setup.cfg index 9519292..0206889 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,3 +9,7 @@ classifiers = Programming Language :: Python :: 3.12 [options] python_requires = >=3.11 +[options.entry_points] +console_scripts = + partial-reset-wiki = miraheze.salt.mwcli.partial-reset-wiki:main + rename-wiki = miraheze.salt.mwcli.rename-wiki:main From 69387031afa9a5a4fd0715c0e478104160941b39 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:33:22 +0100 Subject: [PATCH 27/29] Rename partial-reset-wiki.py to partial_reset_wiki.py --- .../salt/mwcli/{partial-reset-wiki.py => partial_reset_wiki.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename miraheze/salt/mwcli/{partial-reset-wiki.py => partial_reset_wiki.py} (100%) diff --git a/miraheze/salt/mwcli/partial-reset-wiki.py b/miraheze/salt/mwcli/partial_reset_wiki.py similarity index 100% rename from miraheze/salt/mwcli/partial-reset-wiki.py rename to miraheze/salt/mwcli/partial_reset_wiki.py From 5fcf99d1741ecf2f77921d1a09836e7fb487a119 Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:33:30 +0100 Subject: [PATCH 28/29] Rename rename-wiki.py to rename_wiki.py --- miraheze/salt/mwcli/{rename-wiki.py => rename_wiki.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename miraheze/salt/mwcli/{rename-wiki.py => rename_wiki.py} (100%) diff --git a/miraheze/salt/mwcli/rename-wiki.py b/miraheze/salt/mwcli/rename_wiki.py similarity index 100% rename from miraheze/salt/mwcli/rename-wiki.py rename to miraheze/salt/mwcli/rename_wiki.py From ff6e334b6423bc041a90886261aa72782c80db2d Mon Sep 17 00:00:00 2001 From: RhinosF1 Date: Sat, 18 May 2024 13:33:46 +0100 Subject: [PATCH 29/29] Update setup.cfg --- setup.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 0206889..f12093f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,5 +11,5 @@ classifiers = python_requires = >=3.11 [options.entry_points] console_scripts = - partial-reset-wiki = miraheze.salt.mwcli.partial-reset-wiki:main - rename-wiki = miraheze.salt.mwcli.rename-wiki:main + partial-reset-wiki = miraheze.salt.mwcli.partial_reset_wiki:main + rename-wiki = miraheze.salt.mwcli.rename_wiki:main