Changeset 2ac545d
- Timestamp:
- 04/27/2009 06:50:41 PM (16 years ago)
- Branches:
- 2.0.x, develop, extjs4-port, master
- Children:
- 8582915
- Parents:
- 725198
- Location:
- deluge
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
deluge/core/daemon.py
r725198 r2ac545d 22 22 # Boston, MA 02110-1301, USA. 23 23 # 24 25 import signal26 24 27 25 import gettext … … 52 50 log.error("Unable to initialize gettext/locale: %s", e) 53 51 54 # Setup signals55 signal.signal(signal.SIGINT, self.shutdown)56 signal.signal(signal.SIGTERM, self.shutdown)57 if not deluge.common.windows_check(): 58 signal.signal(signal.SIGHUP, self.shutdown)59 else:52 # Twisted catches signals to terminate, so just have it call the shutdown 53 # method. 54 reactor.addSystemEventTrigger("after", "shutdown", self.shutdown) 55 56 # Catch some Windows specific signals 57 if deluge.common.windows_check(): 60 58 from win32api import SetConsoleCtrlHandler 61 59 from win32con import CTRL_CLOSE_EVENT -
deluge/ui/gtkui/gtkui.py
r725198 r2ac545d 34 34 import locale 35 35 import pkg_resources 36 import signal37 36 import gtk, gtk.glade 38 37 … … 133 132 except: 134 133 pass 135 signal.signal(signal.SIGINT, self.shutdown) 136 signal.signal(signal.SIGTERM, self.shutdown) 134 135 # Twisted catches signals to terminate, so just have it call the shutdown 136 # method. 137 reactor.addSystemEventTrigger("after", "shutdown", self.shutdown) 137 138 138 139 if deluge.common.windows_check(): -
deluge/ui/web/server.py
r725198 r2ac545d 27 27 import locale 28 28 import shutil 29 import signal30 import signal31 29 import urllib 32 30 import gettext … … 93 91 available as Deluge.Config. 94 92 """ 95 93 96 94 def render(self, request): 97 95 return """Deluge = { … … 111 109 Twisted Web resource to handle file uploads 112 110 """ 113 111 114 112 def render(self, request): 115 113 """ … … 117 115 each on a new line. 118 116 """ 119 117 120 118 # Block all other HTTP methods. 121 119 if request.method != "POST": 122 120 request.setResponseCode(http.NOT_ALLOWED) 123 121 return "" 124 122 125 123 if "file" not in request.args: 126 124 request.setResponseCode(http.OK) 127 125 return "" 128 126 129 127 tempdir = os.path.join(tempfile.gettempdir(), "delugeweb") 130 128 if not os.path.isdir(tempdir): … … 146 144 request.render_file = path 147 145 return self 148 146 149 147 def render(self, request): 150 148 if not hasattr(request, "render_file"): … … 160 158 class Tracker(resource.Resource): 161 159 tracker_icons = TrackerIcons() 162 160 163 161 def getChild(self, path, request): 164 162 request.tracker_name = path 165 163 return self 166 164 167 165 def render(self, request): 168 166 headers = {} … … 186 184 request.country = path 187 185 return self 188 186 189 187 def render(self, request): 190 188 headers = {} … … 204 202 205 203 class LookupResource(resource.Resource, component.Component): 206 207 def __init__(self, name, *directories): 204 205 def __init__(self, name, *directories): 208 206 resource.Resource.__init__(self) 209 207 component.Component.__init__(self, name) 210 208 self.__directories = directories 211 209 212 210 @property 213 211 def directories(self): 214 212 return self.__directories 215 213 216 214 def getChild(self, path, request): 217 215 request.path = path 218 216 return self 219 217 220 218 def render(self, request): 221 219 log.debug("Requested path: '%s'", request.path) … … 232 230 class TopLevel(resource.Resource): 233 231 addSlash = True 234 232 235 233 __stylesheets = [ 236 234 "/css/ext-all.css", … … 238 236 "/css/deluge.css" 239 237 ] 240 238 241 239 __scripts = [ 242 240 "/js/ext-base.js", … … 247 245 "/js/deluge-yc.js" 248 246 ] 249 247 250 248 __debug_scripts = [ 251 249 "/js/ext-base.js", … … 289 287 "/js/Deluge.UI.js" 290 288 ] 291 289 292 290 def __init__(self): 293 291 resource.Resource.__init__(self) … … 304 302 self.putChild("themes", static.File(rpath("themes"))) 305 303 self.putChild("tracker", Tracker()) 306 304 307 305 theme = component.get("DelugeWeb").config["theme"] 308 306 self.__stylesheets.append("/css/xtheme-%s.css" % theme) … … 311 309 def scripts(self): 312 310 return self.__scripts 313 311 314 312 @property 315 313 def debug_scripts(self): 316 314 return self.__debug_scripts 317 315 318 316 @property 319 317 def stylesheets(self): 320 318 return self.__stylesheets 321 319 322 320 def getChild(self, path, request): 323 321 if path == "": … … 331 329 else: 332 330 scripts = self.scripts[:] 333 331 334 332 template = Template(filename=rpath("index.html")) 335 333 request.setHeader("content-type", "text/html; charset=utf-8") … … 337 335 338 336 class DelugeWeb(component.Component): 339 337 340 338 def __init__(self): 341 339 super(DelugeWeb, self).__init__("DelugeWeb") 342 340 self.config = ConfigManager("web.conf", CONFIG_DEFAULTS) 343 341 344 342 self.top_level = TopLevel() 345 343 self.site = server.Site(self.top_level) 346 344 self.port = self.config["port"] 347 345 self.web_api = WebApi() 348 346 349 347 # Since twisted assigns itself all the signals may as well make 350 348 # use of it. … … 363 361 return 1 364 362 SetConsoleCtrlHandler(win_handler) 365 363 366 364 # Initalize the plugins 367 365 self.plugins = PluginManager()
Note:
See TracChangeset
for help on using the changeset viewer.