diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-06-21 15:36:15 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-06-21 15:36:15 +0200 |
commit | dd709581d5750d11eaa8e96f64ff62f16b8f6201 (patch) | |
tree | f2652e5a64b4730900640368db4724a15542e08f | |
parent | Änderung: 1564:40817b13d8b3 (diff) | |
download | pyload-dd709581d5750d11eaa8e96f64ff62f16b8f6201.tar.xz |
rename process
-rw-r--r-- | b/module/lib/rename_process.py | 21 | ||||
-rw-r--r-- | module/lib/rename_process.py | 17 | ||||
-rw-r--r-- | pyLoadCli.py | 4 | ||||
-rwxr-xr-x | pyLoadCore.py | 4 | ||||
-rwxr-xr-x | pyLoadGui.py | 4 |
5 files changed, 32 insertions, 18 deletions
diff --git a/b/module/lib/rename_process.py b/b/module/lib/rename_process.py new file mode 100644 index 000000000..2aa270171 --- /dev/null +++ b/b/module/lib/rename_process.py @@ -0,0 +1,21 @@ +import sys +import os.path + + +def RenameProcess(new_name): + """ Renames the process calling the function to the given name. """ + if sys.platform != 'linux2': + print 'Unsupported platform' + return False + try: + import ctypes + is_64 = os.path.exists('/lib64/libc.so.6') + if is_64: + libc = ctypes.CDLL('/lib64/libc.so.6') + else: + libc = ctypes.CDLL('/lib/libc.so.6') + libc.prctl(15, new_name, 0, 0, 0) + return True + except: + print "rename failed" + return False diff --git a/module/lib/rename_process.py b/module/lib/rename_process.py index 2aa270171..8d74387f3 100644 --- a/module/lib/rename_process.py +++ b/module/lib/rename_process.py @@ -1,21 +1,14 @@ import sys -import os.path - -def RenameProcess(new_name): +def renameProcess(new_name): """ Renames the process calling the function to the given name. """ if sys.platform != 'linux2': - print 'Unsupported platform' return False try: - import ctypes - is_64 = os.path.exists('/lib64/libc.so.6') - if is_64: - libc = ctypes.CDLL('/lib64/libc.so.6') - else: - libc = ctypes.CDLL('/lib/libc.so.6') + from ctypes import CDLL + libc = CDLL('libc.so.6') libc.prctl(15, new_name, 0, 0, 0) return True - except: - print "rename failed" + except Exception, e: + print "Rename process failed", e return False diff --git a/pyLoadCli.py b/pyLoadCli.py index 92d382db1..29f39656b 100644 --- a/pyLoadCli.py +++ b/pyLoadCli.py @@ -42,7 +42,7 @@ from module.utils import formatSize, decode import ConfigParser from module.remote.thriftbackend.ThriftClient import ThriftClient, NoConnection, NoSSL, WrongLogin, ConnectionClosed from module.lib.Getch import Getch -from module.lib.rename_process import RenameProcess +from module.lib.rename_process import renameProcess class Cli: def __init__(self, client, command): @@ -428,7 +428,7 @@ def writeConfig(opts): print _("Couldn't write user config file") if __name__ == "__main__": - RenameProcess('pyLoadCli') + renameProcess('pyLoadCli') config = {"addr": "127.0.0.1", "port": "7227", "language": "en"} try: config["language"] = os.environ["LANG"][0:2] diff --git a/pyLoadCore.py b/pyLoadCore.py index 5197e4a9a..ccaa61a22 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -56,7 +56,6 @@ from module.remote.RemoteManager import RemoteManager from module.database import DatabaseBackend from module.database import FileHandler -from module.lib.rename_process import RenameProcess from module.utils import freeSpace, formatSize, compare_time @@ -917,7 +916,8 @@ def deamon(): # And so it begins... if __name__ == "__main__": #change name to 'pyLoadCore' - RenameProcess('pyLoadCore') + #from module.lib.rename_process import renameProcess + #renameProcess('pyLoadCore') if "--daemon" in sys.argv: deamon() diff --git a/pyLoadGui.py b/pyLoadGui.py index d5c20bb83..87b501ee2 100755 --- a/pyLoadGui.py +++ b/pyLoadGui.py @@ -45,7 +45,7 @@ from module.gui.Collector import * from module.gui.XMLParser import * from module.gui.CoreConfigParser import ConfigParser -from module.lib.rename_process import RenameProcess +from module.lib.rename_process import renameProcess from module.remote.thriftbackend.thriftgen.pyload.ttypes import * @@ -780,7 +780,7 @@ class Notification(QObject): self.tray.showMessage("pyload", body) if __name__ == "__main__": - RenameProcess('pyLoadGui') + renameProcess('pyLoadGui') app = main() app.loop() |