Skip to content

Commit

Permalink
Merge branch 'pr/96' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
MCMi460 committed Aug 12, 2023
2 parents c021cda + e520a0d commit d1b2003
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
steps:
- uses: actions/checkout@v3

# MacOS Build
# MacOS Universal Build
- name: "Install Python 3.11.4 and build NSO-RPC"
run: |
curl https://www.python.org/ftp/python/3.11.4/python-3.11.4-macos11.pkg -o python-3.11.4-macos11.pkg
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ build/
dist/
setup.py
*.spec
client/version.txt

# Tests
test*.*
Expand Down
15 changes: 15 additions & 0 deletions client/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import git

if __name__ == '__main__':
# Deletes current version.txt file
if os.path.exists('version.txt'):
os.remove('version.txt')

# Writes latest git version info to 'version.txt'
r = git.repo.Repo(search_parent_directories=True)
version_info = r.git.describe('--tags')
with open('version.txt', 'w') as f:
f.write(version_info)
f.write('\n')
f.close()
21 changes: 20 additions & 1 deletion client/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
app.setQuitOnLastWindowClosed(False)
app.setApplicationName("NSO-RPC")
MainWindow = QMainWindow()

# NSO Variables
session_token, user_lang, targetID = getToken(False)
version = getVersion()
Expand Down Expand Up @@ -160,6 +161,17 @@ def timeSince(epoch: int):
}
userSelected = ''

# Get Version Info
try:
with open(getPath('version.txt'), 'r') as file:
versionTag = file.read().rstrip()
try:
versionTag = versionTag.split('-', 1)
except ValueError:
pass
except:
pass


def writeSettings():
try:
Expand Down Expand Up @@ -383,7 +395,7 @@ def assignVariables(self):
self.startOnLaunch.setGeometry(QRect(101, 160, 60, 41))

self.fakePushButton = QPushButton()
self.fakePushButton.clicked.connect(lambda a : self.label_22.setText(altLink))
self.fakePushButton.clicked.connect(lambda a: self.label_22.setText(altLink))

# [MacOS] Hide Buttons if running app.py directly.
if platform.system() == "Darwin" and not isScriptBundled:
Expand All @@ -392,6 +404,13 @@ def assignVariables(self):
self.startInSystemTray.setHidden(True)
self.label_17.setHidden(True)

# Version Details
if versionTag is not None:
if len(versionTag) >= 2:
self.label_5.setText("NSO-RPC" + '\n' + versionTag[0] + "\n" + versionTag[1])
else:
self.label_5.setText("NSO-RPC" + '\n' + versionTag[0])

def closeEvent(self, event = None):
if self.mode == 1:
sys.exit('User closed')
Expand Down
2 changes: 1 addition & 1 deletion client/layout/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ If you'd like to use this app for Discord Rich Presence purposes, please link an
<x>130</x>
<y>20</y>
<width>71</width>
<height>21</height>
<height>61</height>
</rect>
</property>
<property name="text">
Expand Down
2 changes: 1 addition & 1 deletion client/layout/qt5_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def setupUi(self, MainWindow):
self.label_4.setText("")
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(self.groupBox_2)
self.label_5.setGeometry(QtCore.QRect(130, 20, 71, 21))
self.label_5.setGeometry(QtCore.QRect(130, 20, 71, 61))
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(self.groupBox_2)
self.label_6.setGeometry(QtCore.QRect(100, 20, 21, 21))
Expand Down
2 changes: 1 addition & 1 deletion client/layout/qt6_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def setupUi(self, MainWindow):
self.label_4.setText("")
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(parent=self.groupBox_2)
self.label_5.setGeometry(QtCore.QRect(130, 20, 71, 21))
self.label_5.setGeometry(QtCore.QRect(130, 20, 71, 61))
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(parent=self.groupBox_2)
self.label_6.setGeometry(QtCore.QRect(100, 20, 21, 21))
Expand Down
7 changes: 5 additions & 2 deletions scripts/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ if "%PYQT_PACKAGE%"=="" (
echo Building with %PYQT_PACKAGE%

REM Install requirements
python -m pip install -r ../client/requirements.txt pypiwin32 winshell pyinstaller>=5.12 pyinstaller-hooks-contrib==2023.4
python -m pip install -r ../client/requirements.txt GitPython pypiwin32 winshell pyinstaller>=5.12 pyinstaller-hooks-contrib==2023.4

REM Generate version.txt
python _version.py

REM Build the executable using PyInstaller
python -m PyInstaller --onefile --clean --noconsole --exclude-module autopep8 --noupx --add-data "*.png;." --icon=icon.ico --name=NSO-RPC ..\client\app.py
python -m PyInstaller --onefile --clean --noconsole --exclude-module autopep8 --noupx --add-data "*.png;." --add-data "version.txt;." --icon=icon.ico --name=NSO-RPC ..\client\app.py

REM Open the 'dist' directory
start .\dist
6 changes: 4 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cd ../client
python3 -m pip install -r requirements.txt py2app
py2applet --make-setup app.py icon.icns "icon.png" "taskbarDark.png" "taskbarLight.png"
python3 -m pip install -r requirements.txt py2app GitPython
python3 _version.py
rm setup.py
py2applet --make-setup app.py icon.icns "icon.png" "taskbarDark.png" "taskbarLight.png" "version.txt"
sed -i '' -e "s/)/ name='NSO-RPC')/" setup.py
python3 setup.py py2app --arch=x86_64 -O2
open dist
3 changes: 2 additions & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ function install_python_bindings {
install_python_bindings

cd ../client
python3 -m pip install -r requirements.txt
python3 -m pip install -r requirements.txt GitPython
python3 _version.py
executableDir='/opt/NSO-RPC/'

# Check if installation directory already exists
Expand Down

0 comments on commit d1b2003

Please sign in to comment.