]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
PAL9538
authorvsr <vsr@opencascade.com>
Thu, 3 Nov 2005 07:09:15 +0000 (07:09 +0000)
committervsr <vsr@opencascade.com>
Thu, 3 Nov 2005 07:09:15 +0000 (07:09 +0000)
bin/killSalome.py
bin/killSalomeWithPort.py
bin/runSalome.py

index 7ed1d63725772a1f8904373028f2982ba796e19d..d03c8f98c47d984e2fa07033b930f214cb512b50 100755 (executable)
@@ -1,16 +1,16 @@
 #!/usr/bin/env python
-import os, string, sys
+import os, string, sys, re
 
-from killSalomeWithPort import killMyPort
+from killSalomeWithPort import killMyPort, getPiDict
 
 def killAllPorts():
     user = os.getenv('USER')
+    filedict = "^%s$"%(getPiDict('(\d*)',full=False))
+    fnamere = re.compile(filedict)
     for file in os.listdir(os.getenv("HOME")):
-        l = string.split(file, "_")
-        if len(l) >= 4:
-            if file[:len(user)] == user:
-                if l[len(l)-2] == "SALOME" and l[len(l)-1] == "pidict":
-                    killMyPort(l[len(l)-3])
+        mo = re.match(fnamere,file)
+        if mo and len(mo.groups()):
+            killMyPort(mo.groups()[0])
         pass
 
 if __name__ == "__main__":
index bf02709cf6e1480678abea387ac9bf4902407bea..221ba981e30791ffa5983c48b3f6683bf91f7c8d 100755 (executable)
@@ -1,9 +1,22 @@
 #!/usr/bin/env python
 import os, sys, pickle, signal, commands
 
+def getPiDict(port,appname='salome',full=True):
+    filedict = []
+    filedict.append( os.getenv('USER') )          # user name
+    filedict.append( os.getenv('HOSTNAME') )      # host name
+    filedict.append( str(port) )                  # port number
+    filedict.append( appname.upper() )            # application name
+    filedict.append( 'pidict' )                   # constant part
+
+    filedict = '_'.join(filedict)
+    if full:
+        filedict = os.getenv("HOME") + '/' + filedict
+    return filedict
+
 ########## kills all salome processes with the given port ##########
 def killMyPort(port):
-    filedict=os.getenv("HOME")+'/'+os.getenv('USER')+"_"+port+'_SALOME_pidict'
+    filedict=getPiDict(port)
     found = 0
     try:
         fpid=open(filedict, 'r')
index a9bd9237044a8d24135277535ae1b939f4acc4dc..c3ac66070824e81d913b0b81bdb3d44577941456 100755 (executable)
@@ -673,10 +673,10 @@ def useSalome(args, modules_list, modules_root_dir):
         print "--- erreur au lancement Salome ---"
         
     #print process_id
-    
-    filedict = os.getenv("HOME") + '/' + os.getenv('USER') + "_" + str(args['port']) \
-             + '_' + args['appname'].upper() + '_pidict'
-   
+
+    from killSalomeWithPort import getPiDict
+    filedict = getPiDict(args['port'], args['appname'])
+
     process_ids = []
     try:
         fpid=open(filedict, 'r')