Skip to content

Commit

Permalink
merge from master
Browse files Browse the repository at this point in the history
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
  • Loading branch information
giampaolo committed Jul 5, 2024
2 parents 2a99dfc + eef1696 commit f05709d
Show file tree
Hide file tree
Showing 28 changed files with 435 additions and 1,290 deletions.
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ include docs/tutorial.rst
include make.bat
include pyftpdlib/__init__.py
include pyftpdlib/__main__.py
include pyftpdlib/_asynchat.py
include pyftpdlib/_asyncore.py
include pyftpdlib/authorizers.py
include pyftpdlib/filesystems.py
include pyftpdlib/handlers.py
include pyftpdlib/handlers.py
include pyftpdlib/handlers.py
include pyftpdlib/ioloop.py
include pyftpdlib/log.py
include pyftpdlib/prefork.py
Expand Down
6 changes: 3 additions & 3 deletions demo/anti_flood_ftpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def process_command(self, *args, **kwargs):
def ban(self, ip):
# ban ip and schedule next un-ban
if ip not in self.banned_ips:
self.log('banned IP %s for command flooding' % ip)
self.respond('550 You are banned for %s seconds.' % self.ban_for)
self.log(f'banned IP {ip} for command flooding')
self.respond(f'550 You are banned for {self.ban_for} seconds.')
self.close()
self.banned_ips.append(ip)

Expand All @@ -63,7 +63,7 @@ def unban(self, ip):
except ValueError:
pass
else:
self.log('unbanning IP %s' % ip)
self.log(f'unbanning IP {ip}')

def close(self):
FTPHandler.close(self)
Expand Down
35 changes: 17 additions & 18 deletions demo/unix_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ def stop():
try:
os.kill(pid, sig)
except ProcessLookupError:
print("\nstopped (pid %s)" % pid)
print(f"\nstopped (pid {pid})")
i += 1
if i == 25:
sig = signal.SIGKILL
elif i == 50:
sys.exit("\ncould not kill daemon (pid %s)" % pid)
sys.exit(f"\ncould not kill daemon (pid {pid})")
time.sleep(0.1)


Expand All @@ -102,7 +102,7 @@ def status():
if not pid or not pid_exists(pid):
print("daemon not running")
else:
print("daemon running with pid %s" % pid)
print(f"daemon running with pid {pid}")
sys.exit(0)


Expand Down Expand Up @@ -148,12 +148,12 @@ def _daemonize():
# write pidfile
pid = str(os.getpid())
with open(PID_FILE, 'w') as f:
f.write("%s\n" % pid)
f.write(f"{pid}\n")
atexit.register(lambda: os.remove(PID_FILE))

pid = get_pid()
if pid and pid_exists(pid):
sys.exit('daemon already running (pid %s)' % pid)
sys.exit(f'daemon already running (pid {pid})')
# instance FTPd before daemonizing, so that in case of problems we
# get an exception here and exit immediately
server = get_server()
Expand Down Expand Up @@ -193,20 +193,19 @@ def main():
if not options.command:
server = get_server()
server.serve_forever()
else:
if options.command == 'start':
daemonize()
elif options.command == 'stop':
elif options.command == 'start':
daemonize()
elif options.command == 'stop':
stop()
elif options.command == 'restart':
try:
stop()
elif options.command == 'restart':
try:
stop()
finally:
daemonize()
elif options.command == 'status':
status()
else:
sys.exit('invalid command')
finally:
daemonize()
elif options.command == 'status':
status()
else:
sys.exit('invalid command')


if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_version():

# General information about the project.
project = PROJECT_NAME
copyright = '2009-%s, %s' % (THIS_YEAR, AUTHOR)
copyright = f'2009-{THIS_YEAR}, {AUTHOR}'
author = AUTHOR

# The version info for the project you're documenting, acts as replacement for
Expand Down Expand Up @@ -269,7 +269,7 @@ def get_version():
# html_search_scorer = 'scorer.js'

# Output file base name for HTML help builder.
htmlhelp_basename = '%s-doc' % PROJECT_NAME
htmlhelp_basename = f'{PROJECT_NAME}-doc'

# -- Options for LaTeX output ---------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion pyftpdlib/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def main(args=None):

options = parser.parse_args(args=args)
if options.version:
sys.exit("pyftpdlib %s" % __ver__)
sys.exit(f"pyftpdlib {__ver__}")
if options.debug:
config_logging(level=logging.DEBUG)

Expand Down
218 changes: 0 additions & 218 deletions pyftpdlib/_asynchat.py

This file was deleted.

Loading

0 comments on commit f05709d

Please sign in to comment.