1+ #!/bin/python3.7
12# -*- coding: utf-8 -*-
23"""
34Jsmod2 is a java-based scpsl server initiated by jsmod2.cn.
1516import glob
1617import os
1718import platform
18- import re
1919import subprocess
20- import matplotlib .pyplot as plt
2120
2221from requests import get
2322from os .path import expanduser
2423from xmlrpc .client import *
2524
25+
2626home = expanduser ('~' )
2727
2828linuxurl = 'https://dl.jymc.top/java/jre_x86.tar.gz'
2929linuxurl64 = 'https://dl.jymc.top/java/jre_x64.tar.gz'
3030# 采用我的下载服务器下载java
3131windowsurl = 'https://dl.jymc.top/java/windows-i586.tar.gz'
3232windowsurl64 = 'https://dl.jymc.top/java/windows-x64.tar.gz'
33-
34-
33+ print ("{0}/manager.properties" .format (os .getcwd ()))
34+ if not os .path .exists ("{0}/manager.properties" .format (os .getcwd ())):
35+ managerproperties = "rpc.port=20020\n rpc.server=127.0.0.1\n jsmod2.option=\n jvm.option="
36+ print (open (os .getcwd ()+ "/manager.properties" ,"w" ).write (managerproperties ))
3537# 采用我的下载服务器下载java
3638
3739def installwindows ():
@@ -95,28 +97,17 @@ def download(url):
9597 system = 'linux'
9698if platform .system () == 'Windows' :
9799 system = 'windows'
98- # if platform.system() == 'Darwin':
99- # os._exit(0)
100- # Form implementation generated from reading ui file 'Jsmod2Manager.ui'
101- #
102- # Created by: PyQt5 UI code generator 5.13.0
103- #
104- # WARNING! All changes made in this file will be lost!
105100
106-
107- from PyQt5 import QtCore , QtWidgets
108101from PyQt5 .QtCore import pyqtSignal
109102from PyQt5 .QtWidgets import QApplication , QMainWindow
110103
111- # -*- coding: utf-8 -*-
112104
113105# Form implementation generated from reading ui file 'JSmod2Manager.ui'
114106#
115107# Created by: PyQt5 UI code generator 5.13.0
116108#
117109# WARNING! All changes made in this file will be lost!
118110
119-
120111from PyQt5 import QtCore , QtGui , QtWidgets
121112
122113
@@ -476,7 +467,7 @@ def changejsmod2option(self):
476467 keyvalue ["jvm.option" ] = self .jvm .toPlainText ()
477468 print (keyvalue )
478469 emm = str (keyvalue ).replace ("{" ,"" ).replace ("}" ,"" ).replace ("\' " ,"" ).replace (":" ,"=" ).replace ("," ,"\n " ).replace (" " ,"" )
479- properties = open (os .getcwd () + "/../ manager.properties" , "w" )
470+ properties = open (os .getcwd () + "/manager.properties" , "w" )
480471 print (properties .write (emm ))
481472 properties .close ()
482473 def loadplugin (self ):
@@ -504,25 +495,25 @@ def checktype(self, item):
504495 def refreshpluginlist (self ):
505496 self .PluginsList .clear ()
506497 enabled = []
507- for file in glob .glob (os .getcwd () + "/../ plugins/*.jar" ):
498+ for file in glob .glob (os .getcwd () + "/plugins/*.jar" ):
508499 enabled .append (file )
509500 self .PluginsList .addItem (file .split ("/" )[- 1 :][0 ])
510501 disabled = []
511- for file in glob .glob (os .getcwd () + "/../ plugins/*.disabled" ):
502+ for file in glob .glob (os .getcwd () + "/plugins/*.disabled" ):
512503 disabled .append (file )
513504 self .PluginsList .addItem (file .split ("/" )[- 1 :][0 ])
514505
515506 def disable (self ):
516507 plugin = self .PluginsList .currentItem ().text ()
517508 self .unloadplugin ()
518- os .rename (os .getcwd () + "/../ plugins/" + plugin ,
519- (os .getcwd () + "/../ plugins/" + plugin + ".disabled" ).replace (".jar" , "" ))
509+ os .rename (os .getcwd () + "/plugins/" + plugin ,
510+ (os .getcwd () + "/plugins/" + plugin + ".disabled" ).replace (".jar" , "" ))
520511 self .refreshpluginlist ()
521512
522513 def enable (self ):
523514 plugin = self .PluginsList .currentItem ().text ()
524- os .rename (os .getcwd () + "/../ plugins/" + plugin ,
525- (os .getcwd () + "/../ plugins/" + plugin + ".jar" ).replace (".disabled" , "" ))
515+ os .rename (os .getcwd () + "/plugins/" + plugin ,
516+ (os .getcwd () + "/plugins/" + plugin + ".jar" ).replace (".disabled" , "" ))
526517 self .loadplugin ()
527518 self .refreshpluginlist ()
528519
@@ -538,17 +529,15 @@ def __del__(self):
538529 def run (self ):
539530 try :
540531 for line in runprocess ((home + r'/.JSMOD2/java/jre1.8.0_211/bin/java -jar ' + os .path .abspath (
541- os .path .join (os .getcwd (), ".. " )) + '/jsmod2.jar -rpc ' + keyvalue ["rpc.port" ]).split ()):
532+ os .path .join (os .getcwd (), "." )) + '/jsmod2.jar -rpc ' + keyvalue ["rpc.port" ]).split ()):
542533 self .signal .emit (line .decode ().replace ("\n " , "" ))
543534 except :
544535 try :
545536 for line in runprocess ((r'java -jar ' + os .path .abspath (
546- os .path .join (os .getcwd (), ".. " )) + '/jsmod2.jar -rpc ' + keyvalue ["rpc.port" ]).split ()):
537+ os .path .join (os .getcwd (), "." )) + '/jsmod2.jar -rpc ' + keyvalue ["rpc.port" ]).split ()):
547538 self .signal .emit (line .decode ().replace ("\n " , "" ))
548539 except :
549540 print ("您的系统不支持并且系统没有java too sad :(" )
550- sys .exit (1 )
551-
552541 def detect (self ):
553542 print (self .treeWidget .selectedIndexes ())
554543 getSelected = self .treeWidget .selectedItems ()
@@ -764,7 +753,7 @@ def plugin_info(self, plugin):
764753 except :
765754 pass
766755
767- properties = open (os .getcwd () + "/../ manager.properties" ,"r+" )
756+ properties = open (os .getcwd () + "/manager.properties" ,"r+" )
768757keyvalue = {"" :"" }
769758for line in properties .readlines ():
770759 if line [0 ] == "#" :
@@ -777,6 +766,6 @@ def plugin_info(self, plugin):
777766ui = Ui_JSmod2Manager ()
778767ui .setupUi (MainWindow )
779768MainWindow .show ()
780- # MainWindow.setFixedSize(600, 411 )
769+ MainWindow .setFixedSize (932 , 450 )
781770MainWindow .setWindowTitle ("JSmod2启动器" )
782771app .exit (app .exec_ ())
0 commit comments