A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

tips.rst 2.4 KiB

il y a 12 ans
il y a 12 ans
il y a 12 ans
il y a 12 ans
il y a 12 ans
il y a 12 ans
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. Tips
  2. ====
  3. - Logging_ is a fantastic way to monitor the bot's progress as it runs. It has
  4. a slew of built-in loggers, and enabling log retention (so logs are saved to
  5. :file:`logs/` in the working directory) is highly recommended. In the normal
  6. setup, there are three log files, each of which "rotate" at a specific time
  7. (:file:`filename.log` becomes :file:`filename.log.2012-04-10`, for example).
  8. The :file:`debug.log` file rotates every hour, and maintains six hours of
  9. logs of every level (``DEBUG`` and up). :file:`bot.log` rotates every day at
  10. midnight, and maintains seven days of non-debug logs (``INFO`` and up).
  11. Finally, :file:`error.log` rotates every Sunday night, and maintains four
  12. weeks of logs indicating unexpected events (``WARNING`` and up).
  13. To use logging in your commands or tasks (recommended),
  14. :py:class:~earwigbot.commands.BaseCommand` and
  15. :py:class:~earwigbot.tasks.BaseTask` provide :py:attr:`logger` attributes
  16. configured for the specific command or task. If you're working with other
  17. classes, :py:attr:`bot.logger` is the root logger
  18. (:py:obj:`logging.getLogger("earwigbot")` by default), so you can use
  19. :py:func:`~logging.Logger.getChild` to make your logger. For example, task
  20. loggers are essentially
  21. :py:attr:`bot.logger.getChild("tasks").getChild(task.name) <bot.logger>`.
  22. - A very useful IRC command is "``!reload``", which reloads all commands and
  23. tasks without restarting the bot. [1]_ Combined with using the `!git plugin`_
  24. for pulling repositories from IRC, this can provide a seamless command/task
  25. development workflow if the bot runs on an external server and you set up
  26. its working directory as a git repo.
  27. - You can run a task by itself instead of the entire bot with
  28. :command:`earwigbot path/to/working/dir --task task_name`.
  29. - Questions, comments, or suggestions about the documentation? `Let me know`_,
  30. or `create an issue`_ so I can improve it for other people.
  31. .. rubric:: Footnotes
  32. .. [1] In reality, all this does is call :py:meth:`bot.commands.load()
  33. <earwigbot.managers._ResourceManager.load>` and
  34. :py:meth:`bot.tasks.load() <earwigbot.managers._ResourceManager.load>`!
  35. .. _logging: http://docs.python.org/library/logging.html
  36. .. _!git plugin: https://github.com/earwig/earwigbot-plugins/blob/develop/commands/git.py
  37. .. _Let me know: ben.kurtovic@verizon.net
  38. .. _create an issue: https://github.com/earwig/earwigbot/issues