summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST.in2
-rw-r--r--pavement.py11
-rwxr-xr-xpyload.py71
-rw-r--r--pyload/Core.py68
-rw-r--r--pyload/InitHomeDir.py5
5 files changed, 79 insertions, 78 deletions
diff --git a/MANIFEST.in b/MANIFEST.in
index cda6ee45e..9c183b361 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -18,5 +18,5 @@ recursive-include tests *.py *.txt *.sh
recursive-include locale *.pot *.mo
-recursive-exclude * __pycache__
+#recursive-exclude * __pycache__
recursive-exclude * *.py[co] \ No newline at end of file
diff --git a/pavement.py b/pavement.py
index a458194b7..654a72df1 100644
--- a/pavement.py
+++ b/pavement.py
@@ -67,12 +67,11 @@ setup(
#setup_requires=["setuptools_hg"],
test_suite='nose.collector',
tests_require=['nose', 'websocket-client >= 0.8.0', 'requests >= 1.2.2'],
- scripts=['pyload.py', 'pyload-cli.py'],
- # entry_points={
- # 'console_scripts': [
- # 'pyload = pyload:main',
- # 'pyload-cli = pyload_cli:main' #TODO fix
- # ]},
+ entry_points={
+ 'console_scripts': [
+ 'pyload = pyload.Core:main',
+ 'pyload-cli = pyload.cli.Cli:main'
+ ]},
zip_safe=False,
classifiers=[
"Development Status :: 5 - Production/Stable",
diff --git a/pyload.py b/pyload.py
index 19d51ed38..340c35e15 100755
--- a/pyload.py
+++ b/pyload.py
@@ -5,81 +5,16 @@
# Copyright(c) 2008-2013 pyLoad Team
# http://www.pyload.org
#
-# This program is free software: you can redistribute it and/or modify
+# This file is part of pyLoad.
+# pyLoad is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# Subjected to the terms and conditions in LICENSE
-#
-# @author: spoob
-# @author: sebnapi
-# @author: RaNaN
-# @author: mkaay
-# @version: v0.5.0
###############################################################################
-import os
-import sys
-from os import _exit
-
-from pyload.Core import Core
-
-def deamon():
- try:
- pid = os.fork()
- if pid > 0:
- sys.exit(0)
- except OSError, e:
- print >> sys.stderr, "fork #1 failed: %d (%s)" % (e.errno, e.strerror)
- sys.exit(1)
-
- # decouple from parent environment
- os.setsid()
- os.umask(0)
-
- # do second fork
- try:
- pid = os.fork()
- if pid > 0:
- # exit from second parent, print eventual PID before
- print "Daemon PID %d" % pid
- sys.exit(0)
- except OSError, e:
- print >> sys.stderr, "fork #2 failed: %d (%s)" % (e.errno, e.strerror)
- sys.exit(1)
-
- # Iterate through and close some file descriptors.
- for fd in range(0, 3):
- try:
- os.close(fd)
- except OSError: # ERROR, fd wasn't open to begin with (ignored)
- pass
-
- os.open(os.devnull, os.O_RDWR) # standard input (0)
- os.dup2(0, 1) # standard output (1)
- os.dup2(0, 2)
-
- pyload_core = Core()
- pyload_core.start()
-
-
-def main():
- #change name to 'pyLoadCore'
- #from module.lib.rename_process import renameProcess
- #renameProcess('pyLoadCore')
- if "--daemon" in sys.argv:
- deamon()
- else:
- pyload_core = Core()
- try:
- pyload_core.start()
- except KeyboardInterrupt:
- pyload_core.shutdown()
- pyload_core.log.info(_("killed pyLoad from terminal"))
- pyload_core.removeLogger()
- _exit(1)
+from pyload.Core import main
-# And so it begins...
if __name__ == "__main__":
main() \ No newline at end of file
diff --git a/pyload/Core.py b/pyload/Core.py
index 575eda357..16740bafa 100644
--- a/pyload/Core.py
+++ b/pyload/Core.py
@@ -5,19 +5,25 @@
# Copyright(c) 2008-2013 pyLoad Team
# http://www.pyload.org
#
-# This file is part of pyLoad.
-# pyLoad is free software: you can redistribute it and/or modify
+# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# Subjected to the terms and conditions in LICENSE
+#
+# @author: spoob
+# @author: sebnapi
+# @author: RaNaN
+# @author: mkaay
+# @version: v0.5.0
###############################################################################
CURRENT_VERSION = '0.4.9.9-dev'
import __builtin__
+
from getopt import getopt, GetoptError
import logging
import logging.handlers
@@ -601,3 +607,61 @@ class Core(object):
return join(pypath, *args)
+def deamon():
+ try:
+ pid = os.fork()
+ if pid > 0:
+ sys.exit(0)
+ except OSError, e:
+ print >> sys.stderr, "fork #1 failed: %d (%s)" % (e.errno, e.strerror)
+ sys.exit(1)
+
+ # decouple from parent environment
+ os.setsid()
+ os.umask(0)
+
+ # do second fork
+ try:
+ pid = os.fork()
+ if pid > 0:
+ # exit from second parent, print eventual PID before
+ print "Daemon PID %d" % pid
+ sys.exit(0)
+ except OSError, e:
+ print >> sys.stderr, "fork #2 failed: %d (%s)" % (e.errno, e.strerror)
+ sys.exit(1)
+
+ # Iterate through and close some file descriptors.
+ for fd in range(0, 3):
+ try:
+ os.close(fd)
+ except OSError: # ERROR, fd wasn't open to begin with (ignored)
+ pass
+
+ os.open(os.devnull, os.O_RDWR) # standard input (0)
+ os.dup2(0, 1) # standard output (1)
+ os.dup2(0, 2)
+
+ pyload_core = Core()
+ pyload_core.start()
+
+
+def main():
+ #change name to 'pyLoadCore'
+ #from module.lib.rename_process import renameProcess
+ #renameProcess('pyLoadCore')
+ if "--daemon" in sys.argv:
+ deamon()
+ else:
+ pyload_core = Core()
+ try:
+ pyload_core.start()
+ except KeyboardInterrupt:
+ pyload_core.shutdown()
+ pyload_core.log.info(_("killed pyLoad from terminal"))
+ pyload_core.removeLogger()
+ _exit(1)
+
+# And so it begins...
+if __name__ == "__main__":
+ main() \ No newline at end of file
diff --git a/pyload/InitHomeDir.py b/pyload/InitHomeDir.py
index 3554497d3..c255913de 100644
--- a/pyload/InitHomeDir.py
+++ b/pyload/InitHomeDir.py
@@ -31,7 +31,10 @@ __builtin__.pypath = path.abspath(path.join(__file__, "..", ".."))
# Before changing the cwd, the abspath of the module must be manifested
if 'pyload' in sys.modules:
- sys.modules['pyload'].__path__.append(path.abspath(sys.modules['pyload'].__path__[0]))
+ rel_pyload = sys.modules['pyload'].__path__[0]
+ abs_pyload = path.abspath(rel_pyload)
+ if abs_pyload != rel_pyload:
+ sys.modules['pyload'].__path__.insert(0, abs_pyload)
sys.path.append(join(pypath, "pyload", "lib"))