Code Duplication    Length = 36-37 lines in 2 locations

dev/mini.py 1 location

@@ 393-428 (lines=36) @@
390
            self.frontend_target,
391
        )
392
393
    def _start_server(self, *args):
394
        """Run the node local server"""
395
396
        self.log("Starting server", args)
397
        secure = self.certificate is not None
398
        if secure:
399
            self.log("Running SSL server with cert:", self.certificate)
400
        else:
401
            self.log(
402
                "Running insecure server without SSL. Do not use without SSL proxy in production!",
403
                lvl=warn,
404
            )
405
406
        try:
407
            self.server = Server(
408
                (self.host, self.port),
409
                display_banner=False,
410
                secure=secure,
411
                certfile=self.certificate  # ,
412
                # inherit=True
413
            ).register(self)
414
        except PermissionError as e:
415
            if self.port <= 1024:
416
                self.log(
417
                    "Could not open privileged port (%i), check permissions!"
418
                    % self.port,
419
                    e,
420
                    lvl=critical,
421
                )
422
            else:
423
                self.log("Could not open port (%i):" % self.port, e, lvl=critical)
424
        except OSError as e:
425
            if e.errno == 98:
426
                self.log("Port (%i) is already opened!" % self.port, lvl=critical)
427
            else:
428
                self.log("Could not open port (%i):" % self.port, e, lvl=critical)
429
430
    def _drop_privileges(self, *args):
431
        self.log("Dropping privileges", lvl=debug)

isomer/launcher.py 1 location

@@ 428-464 (lines=37) @@
425
        if "-v" in args:
426
            self.log("Context:", self.context.obj, pretty=True)
427
428
    def _start_server(self):
429
        """Run the node local server"""
430
431
        self.log("Starting server")
432
        secure = self.certificate is not None
433
        if secure:
434
            self.log("Running SSL server with cert:", self.certificate)
435
        else:
436
            self.log(
437
                "Running insecure server without SSL. Do not use without SSL "
438
                "proxy in production!",
439
                lvl=warn,
440
            )
441
442
        try:
443
            self.server = Server(
444
                (self.host, self.port),
445
                display_banner=False,
446
                secure=secure,
447
                certfile=self.certificate  # ,
448
                # inherit=True
449
            ).register(self)
450
        except PermissionError as e:
451
            if self.port <= 1024:
452
                self.log(
453
                    "Could not open privileged port (%i), check permissions!"
454
                    % self.port,
455
                    e,
456
                    lvl=critical,
457
                )
458
            else:
459
                self.log("Could not open port (%i):" % self.port, e, lvl=critical)
460
        except OSError as e:
461
            if e.errno == 98:
462
                self.log("Port (%i) is already opened!" % self.port, lvl=critical)
463
            else:
464
                self.log("Could not open port (%i):" % self.port, e, lvl=critical)
465
466
    def _drop_privileges(self, *args):
467
        self.log("Dropping privileges", lvl=debug)