-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #957 from Capsize-Games/devastator
Devastator
- Loading branch information
Showing
21 changed files
with
276 additions
and
96 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
47 changes: 47 additions & 0 deletions
47
src/airunner/alembic/versions/75020956e3e2_move_username_to_separate_table.py
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,47 @@ | ||
from typing import Sequence, Union | ||
import os | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import sqlite | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = '75020956e3e2' | ||
down_revision: Union[str, None] = '26a0d29a3af3' | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
def convert_image_to_binary(image_path): | ||
with open(image_path, 'rb') as file: | ||
binary_data = file.read() | ||
return binary_data | ||
|
||
def upgrade(): | ||
try: | ||
op.create_table( | ||
'users', | ||
sa.Column('id', sa.Integer, primary_key=True, autoincrement=True), | ||
sa.Column('username', sa.String, nullable=False), | ||
) | ||
op.execute( | ||
sa.text("INSERT INTO users (username) VALUES ('User')") | ||
) | ||
except Exception as e: | ||
print(f"Error during upgrade: {e}") | ||
|
||
try: | ||
op.drop_column('chatbots', 'username') | ||
except Exception as e: | ||
print(f"Column already dropped: {e}") | ||
|
||
def downgrade(): | ||
try: | ||
op.add_column('chatbots', sa.Column('username', sa.String, nullable=True)) | ||
except Exception as e: | ||
print(f"Column already exists: {e}") | ||
|
||
try: | ||
op.drop_table('users') | ||
except Exception as e: | ||
print(f"Table already dropped: {e}") | ||
# ### end Alembic commands ### |
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
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
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
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
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,13 @@ | ||
from PIL import Image | ||
from PIL.ImageQt import QImage | ||
|
||
|
||
def pil_to_qimage(pil_image): | ||
if pil_image.mode == "RGB": | ||
r, g, b = pil_image.split() | ||
pil_image = Image.merge("RGBA", (r, g, b, Image.new("L", r.size, 255))) | ||
elif pil_image.mode == "L": | ||
pil_image = pil_image.convert("RGBA") | ||
data = pil_image.tobytes("raw", "RGBA") | ||
qimage = QImage(data, pil_image.size[0], pil_image.size[1], QImage.Format.Format_RGBA8888) | ||
return qimage |
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,9 @@ | ||
from PIL.ImageQt import QPixmap | ||
|
||
from airunner.utils.convert_pil_to_qimage import pil_to_qimage | ||
|
||
|
||
def convert_pil_to_qpixmap(image): | ||
qimage = pil_to_qimage(image) | ||
pixmap = QPixmap.fromImage(qimage) | ||
return pixmap |
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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
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
Oops, something went wrong.