Skip to content

Commit

Permalink
Merge pull request #401 from dlubal-software/bugfix/psutil
Browse files Browse the repository at this point in the history
Bugfix/psutil
  • Loading branch information
DlubalBot authored Nov 19, 2024
2 parents 73b21e4 + ce60d98 commit 25cd79b
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 38 deletions.
56 changes: 28 additions & 28 deletions RFEM/initModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,34 +893,34 @@ def GetAppSessionId():
# Client Application | Get Session ID
return connectionGlobals.client.service.get_session_id()

def getPathToRunningRFEM():
'''
Find the path to the directory where RFEM is currently running.
This is helpful when using server version, because it can't process relative paths.
'''
import psutil
rstab9 = False
rstab9Server = False
path = ''

for p in psutil.process_iter(['name', 'exe']):
if p.info['name'] == 'RFEM6.exe':
idx = p.info['exe'].find('bin')
path = p.info['exe'][:idx]
elif p.info['name'] == 'RFEM6Server.exe':
idx = p.info['exe'].find('bin')
path = p.info['exe'][:idx]
elif p.info['name'] == 'RSTAB9.exe':
rstab9 = True
elif p.info['name'] == 'RSTAB9Server.exe':
rstab9Server = True

if rstab9 or rstab9Server:
raise ValueError('Careful! You are running RFEM Python Client on RSTAB.')
if not path:
raise ValueError('Is it possible that RFEM is not runnnning?')

return path
# def getPathToRunningRFEM():
# '''
# Find the path to the directory where RFEM is currently running.
# This is helpful when using server version, because it can't process relative paths.
# '''
# import psutil
# rstab9 = False
# rstab9Server = False
# path = ''

# for p in psutil.process_iter(['name', 'exe']):
# if p.info['name'] == 'RFEM6.exe':
# idx = p.info['exe'].find('bin')
# path = p.info['exe'][:idx]
# elif p.info['name'] == 'RFEM6Server.exe':
# idx = p.info['exe'].find('bin')
# path = p.info['exe'][:idx]
# elif p.info['name'] == 'RSTAB9.exe':
# rstab9 = True
# elif p.info['name'] == 'RSTAB9Server.exe':
# rstab9Server = True

# if rstab9 or rstab9Server:
# raise ValueError('Careful! You are running RFEM Python Client on RSTAB.')
# if not path:
# raise ValueError('Is it possible that RFEM is not runnnning?')

# return path

def GetListOfOpenedModels():

Expand Down
3 changes: 2 additions & 1 deletion UnitTests/test_DesignOverview.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
sys.path.append(PROJECT_ROOT)

from RFEM.enums import AddOn
from RFEM.initModel import Model, SetAddonStatus, getPathToRunningRFEM
from RFEM.initModel import Model, SetAddonStatus
from RFEM.connectionGlobals import url
from RFEM.Results.designOverview import GetDesignOverview, GetPartialDesignOverview
from RFEM.Reports.partsList import GetPartsListAllByMaterial, GetPartsListMemberRepresentativesByMaterial
from RFEM.Reports.partsList import GetPartsListMemberSetsByMaterial, GetPartsListMembersByMaterial
from RFEM.Reports.partsList import GetPartsListSolidsByMaterial, GetPartsListSurfacessByMaterial
from tools import getPathToRunningRFEM

if Model.clientModel is None:
Model()
Expand Down
4 changes: 2 additions & 2 deletions UnitTests/test_Export.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
os.pardir)
)
sys.path.append(PROJECT_ROOT)

from tools import getPathToRunningRFEM
from RFEM.enums import ObjectTypes
from RFEM.initModel import Model, closeModel, getPathToRunningRFEM
from RFEM.initModel import Model, closeModel
from RFEM.ImportExport.exports import IFCExportSettings, ObjectLocation, ObjectLocations, ExportToIFC, GetTableExportConfigManager, SetTableExportConfigManager, ExportTo
from RFEM.ImportExport.imports import getConversionTables, setConversionTables, getSAFSettings, setSAFSettings, importFrom
sys.path.append('..')
Expand Down
3 changes: 2 additions & 1 deletion UnitTests/test_GetAllObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
os.pardir)
)
sys.path.append(PROJECT_ROOT)
from RFEM.initModel import Model, getPathToRunningRFEM
from RFEM.initModel import Model
from RFEM.connectionGlobals import url
from RFEM.Tools.GetObjectNumbersByType import GetAllObjects
import pytest
from tools import getPathToRunningRFEM

if Model.clientModel is None:
Model()
Expand Down
3 changes: 2 additions & 1 deletion UnitTests/test_GlobalParameters_Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
import pytest
from RFEM.enums import GlobalParameterUnitGroup, GlobalParameterDefinitionType, ObjectTypes
from RFEM.globalParameter import GlobalParameter
from RFEM.initModel import Model, getPathToRunningRFEM
from RFEM.initModel import Model
from RFEM.connectionGlobals import url
import pytest
from tools import getPathToRunningRFEM

if Model.clientModel is None:
Model()
Expand Down
3 changes: 2 additions & 1 deletion UnitTests/test_Reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
sys.path.append(PROJECT_ROOT)
from RFEM.Reports.printoutReport import PrintoutReport
from RFEM.Reports.html import ExportResultTablesToHtml
from RFEM.initModel import Model, closeModel, openFile, getPathToRunningRFEM
from RFEM.initModel import Model, closeModel, openFile
from RFEM.connectionGlobals import url
from shutil import rmtree
import pytest
import time
from tools import getPathToRunningRFEM

if Model.clientModel is None:
Model()
Expand Down
3 changes: 2 additions & 1 deletion UnitTests/test_ResultTables.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
os.pardir)
)
sys.path.append(PROJECT_ROOT)
from RFEM.initModel import Model, getPathToRunningRFEM
from RFEM.initModel import Model
from RFEM.connectionGlobals import url
from RFEM.enums import CaseObjectType
from RFEM.Results.resultTables import ResultTables
from tools import getPathToRunningRFEM

if Model.clientModel is None:
Model()
Expand Down
3 changes: 2 additions & 1 deletion UnitTests/test_nodalReleaseType.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
)
sys.path.append(PROJECT_ROOT)

from RFEM.initModel import Model, getPathToRunningRFEM
from RFEM.initModel import Model
from RFEM.connectionGlobals import url
from RFEM.enums import NodalReleaseTypeReleaseNonlinearity, NodalReleaseTypePartialActivityAround, NodalReleaseTypeLocalAxisSystemObjectType
from RFEM.enums import NodalReleaseTypePartialActivityAlong, NodalReleaseTypeDiagram
from RFEM.TypesForSpecialObjects.nodalReleaseType import NodalReleaseType
import pytest
from tools import getPathToRunningRFEM

if Model.clientModel is None:
Model()
Expand Down
28 changes: 28 additions & 0 deletions UnitTests/tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
def getPathToRunningRFEM():
'''
Find the path to the directory where RFEM is currently running.
This is helpful when using server version, because it can't process relative paths.
'''
import psutil
rstab9 = False
rstab9Server = False
path = ''

for p in psutil.process_iter(['name', 'exe']):
if p.info['name'] == 'RFEM6.exe':
idx = p.info['exe'].find('bin')
path = p.info['exe'][:idx]
elif p.info['name'] == 'RFEM6Server.exe':
idx = p.info['exe'].find('bin')
path = p.info['exe'][:idx]
elif p.info['name'] == 'RSTAB9.exe':
rstab9 = True
elif p.info['name'] == 'RSTAB9Server.exe':
rstab9Server = True

if rstab9 or rstab9Server:
raise ValueError('Careful! You are running RFEM Python Client on RSTAB.')
if not path:
raise ValueError('Is it possible that RFEM is not runnnning?')

return path
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='RFEM',
version='1.20.2',
version='1.20.3',
description='Python Framework for RFEM6 Web Services',
long_description=readme,
long_description_content_type = "text/markdown",
Expand All @@ -24,6 +24,6 @@
packages=find_packages(),
package_dir={"RFEM":"RFEM"},
include_package_data=True,
install_requires=["requests", "six", "suds-py3", "xmltodict", "pytest", "psutil", "mock", "setuptools"],
install_requires=["requests", "six", "suds-py3", "xmltodict", "pytest", "mock", "setuptools"],
zip_safe = False
)

0 comments on commit 25cd79b

Please sign in to comment.