Skip to content

Commit

Permalink
hotfix
Browse files Browse the repository at this point in the history
- discord intergretion (wip)
- metadata reader
- bug fix
  • Loading branch information
sujeb2 committed Apr 7, 2024
1 parent 1751750 commit 1c0ab78
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 38 deletions.
4 changes: 4 additions & 0 deletions log/debug-log.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[2024-04-07 13:48:11,407] INFO:trying initallizing main frame..
[2024-04-07 13:48:11,499] INFO:initallized.
[2024-04-07 13:48:12,442] INFO:retriving info
[2024-04-07 13:48:12,900] INFO:retriving info
35 changes: 23 additions & 12 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from PyQt6.QtWidgets import QWidget, QApplication, QLabel, QMessageBox, QListView
from PyQt6.QtGui import QIcon, QMouseEvent, QPixmap, QStandardItem, QStandardItemModel, QShortcut, QKeySequence
from PyQt6.QtWidgets import QWidget, QApplication, QLabel, QMessageBox, QListView, QAbstractItemView
from PyQt6.QtGui import QIcon, QPixmap, QStandardItem, QStandardItemModel
from PyQt6 import QtCore
from PyQt6.QtCore import Qt
from functools import partial
import os, logging, sys, subprocess, time
import os, logging, sys, subprocess, json
from src.downloader.downloader import Downloader
from src.metadata import metadata
from src.discord import intergration
from src.createvm import gui
from src.gui.createvm import gui

log = logging
logFilePath = './log/debug-log.log'
Expand Down Expand Up @@ -48,7 +46,6 @@ def __init__(self):
self.setGeometry(self.top, self.left, self.width, self.height)
self.setWindowFlags(QtCore.Qt.WindowType.WindowCloseButtonHint | QtCore.Qt.WindowType.WindowMinimizeButtonHint)
self.setupWidget()
#intergration.runcallback()

log.info('initallized.')
except:
Expand Down Expand Up @@ -78,9 +75,10 @@ def setupWidget(self):

for i in self.sub_folders:
self.model.appendRow(QStandardItem(i))
self.vmListView.setModel(self.model)
self.label_Vm_Title.setText('Select VM to get Started!')
self.label_Vm_Desc.setText('and Press Start VM')
self.vmListView.setModel(self.model)
if len(self.sub_folders) > 0:
self.label_Vm_Title.setText('Select VM to get Started!')
self.label_Vm_Desc.setText('or create another one')

# font
font_bold = self.label_Title.font()
Expand Down Expand Up @@ -121,6 +119,7 @@ def setupWidget(self):
self.vmListView.move(15, 60)

self.vmListView.resize(290, 645)
self.vmListView.clicked[QtCore.QModelIndex].connect(self.on_clicked)

def runQemu(self, iso_loc, disk_loc, mem_size, sys_core):
subprocess.run(f'./src/qemu/qemu.exe -enable-kvm -m {mem_size} -smp {sys_core} -cdrom {iso_loc} -hda {disk_loc} -vga qxl -device AC97 -netdev user,id=net0,net=192.168.0.0,dhcpstart=192.168.0.9')
Expand All @@ -130,8 +129,20 @@ def showCreateVMWindow(self):
self.w = gui.CreateVM()
self.w.show()

def mousePressEvent(self, e):
self.showCreateVMWindow()
def on_clicked(self, index):
log.info('retriving info')
try:
item = self.model.itemFromIndex(index)
f = open('./src/vm/' + item.text() + '/metadata.json', 'r+')
data = json.load(f)

for i in data['desc']:
self.label_Vm_Desc.setText(i)
f.close()

self.label_Vm_Title.setText(item.text())
except:
log.critical('failed to read metadata, is file even?')

if __name__ == '__main__':
app = QApplication(sys.argv[0:])
Expand Down
Binary file modified src/discord/__pycache__/intergration.cpython-312.pyc
Binary file not shown.
30 changes: 8 additions & 22 deletions src/discord/intergration.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
import discordsdk as sdk
from pypresence import Presence
import time

actic = sdk.Discord(1226317055356309504, sdk.CreateFlags.default)
activityManager = actic.get_activity_manager()
clientID = '1226317055356309504'
RPC = Presence(clientID)
RPC.connect()
curState = 'Running through VM'

activity = sdk.Activity()
activity.state = 'Running Through Debugging'
activity.party.id = "00000000"
activity.name = 'Imaginary'
print(RPC.update(details=curState, large_image='star'))


def callback(result):
if result == sdk.Result.ok:
print("Successfully set the activity!")
else:
raise Exception(result)

activityManager = actic.get_activity_manager().update_activity(activity, callback)

def runcallback():
while 1:
time.sleep(1/10)
actic.run_callbacks()

runcallback()
while True:
RPC.update(details=curState, large_image='star')
Empty file added src/gui/createvm/__init__.py
Empty file.
Binary file not shown.
Binary file added src/gui/createvm/__pycache__/gui.cpython-312.pyc
Binary file not shown.
57 changes: 57 additions & 0 deletions src/gui/createvm/gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from PyQt6.QtWidgets import QWidget, QApplication, QLabel, QMessageBox, QListView
from PyQt6.QtGui import QIcon, QPixmap, QStandardItem, QStandardItemModel, QShortcut, QKeySequence
from PyQt6 import QtCore
from PyQt6.QtCore import Qt
import os, sys, logging

log = logging
logFilePath = './log/debug-log.log'

class CreateVM(QWidget):
def __init__(self):
log.info('trying initallizing frame..')
try:
super().__init__()

self.top = 200
self.left = 500
self.width = 640
self.height = 480

self.setWindowTitle("Create VM")
self.setStyleSheet("background-color: #262626;")
self.setWindowIcon(QIcon('./src/png/icons/128.png'))
self.setGeometry(self.top, self.left, self.width, self.height)
self.setWindowFlags(QtCore.Qt.WindowType.WindowCloseButtonHint | QtCore.Qt.WindowType.WindowMinimizeButtonHint)
self.initUI()
log.info('initallized.')
except:
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
log.critical(f"ERROR Occurred!\nLog: {exc_type}, {exc_obj}, {exc_tb}, {fname}")
errInfoWinInit = QMessageBox.critical(self, '오류가 발생하였습니다.', '재설정을 하는 중에 오류가 발생했습니다.\n보통 프로그램이 꼬였거나, 저장된 위치에 한글이 들어있으면 안되는 경우가 있습니다.')
log.critical('failed to intiallized window')

def initUI(self):
self.label_Title = QLabel('Create QEMU VM', self)


# font
font_bold = self.label_Title.font()
font_bold.setBold(True)
font_bold.setPointSize(20)
font_bold.setFamily('Figtree')

font_bold_title = self.label_Title.font()
font_bold_title.setBold(True)
font_bold_title.setPointSize(30)
font_bold_title.setFamily('Figtree')

font_button = self.label_Title.font()
font_button.setBold(True)
font_button.setPointSize(15)
font_button.setFamily('Figtree')

self.label_Title.move(20, 15)
self.label_Title.setFont(font_bold_title)
self.label_Title.setStyleSheet("Color : white;")
Empty file added src/gui/info/__init__.py
Empty file.
39 changes: 39 additions & 0 deletions src/gui/info/info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from PyQt6.QtWidgets import QWidget, QApplication, QLabel, QMessageBox, QListView
from PyQt6.QtGui import QIcon, QPixmap, QStandardItem, QStandardItemModel, QShortcut, QKeySequence
from PyQt6 import QtCore
from PyQt6.QtCore import Qt
import os, sys, logging

log = logging
logFilePath = './log/debug-log.log'

class CreateVM(QWidget):
def __init__(self):
log.info('trying initallizing frame..')
try:
super().__init__()

self.top = 200
self.left = 500
self.width = 640
self.height = 480

self.setWindowTitle("Imaingary INFO")
self.setStyleSheet("background-color: #262626;")
self.setWindowIcon(QIcon('./src/png/icons/128.png'))
self.setGeometry(self.top, self.left, self.width, self.height)
self.setWindowFlags(QtCore.Qt.WindowType.WindowCloseButtonHint | QtCore.Qt.WindowType.WindowMinimizeButtonHint)
self.initUI()
log.info('initallized.')
except:
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
log.critical(f"ERROR Occurred!\nLog: {exc_type}, {exc_obj}, {exc_tb}, {fname}")
errInfoWinInit = QMessageBox.critical(self, '오류가 발생하였습니다.', '재설정을 하는 중에 오류가 발생했습니다.\n보통 프로그램이 꼬였거나, 저장된 위치에 한글이 들어있으면 안되는 경우가 있습니다.')
log.critical('failed to intiallized window')

def initUI(self):
self.label_Logo = QLabel(self)
self.label_Logo.setPixmap(QPixmap('./src/png/icons/128.png'))

self.label_Logo.move(15, 15)
5 changes: 1 addition & 4 deletions src/vm/isthisareallife/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"sys_core": 2,
"mem_size": 4,
"iso_loc": "./testiso.iso",
"disk_loc": "./disk.qcow2"
"desc": "of"
}
3 changes: 3 additions & 0 deletions src/vm/orisitjustafantasy/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"desc": "end"
}

0 comments on commit 1c0ab78

Please sign in to comment.