103 Commits

Author SHA1 Message Date
jack1142
b36a702e62
Make command usage in help for required arguments consistent (#4589)
* Make command usage in help for required arguments consistent

* Bob 3

* Bob 1

* Docstring updates

* Address Flame's review

* Update cog guides in docs
2020-12-22 14:14:47 -05:00
bobloy
c7fd561cd5
[Docs] Downloader cog guide (#4511)
* Downloader cog guide initial commit

* Updated cogguide to prepare description on cog as well.

* Lots of docstring updates

* Even more docstrings

* Fix docstring and generate docs

* Switch to alphabetical

* Aliases are `in ticks and fully qualified`

* Fix grammer, arguments, and explain revision.

* Regenerated docs

* Avoid ticks in links

* New URL logic

* Additional grammar fixes

* Regenerate docs
2020-11-20 20:18:04 -05:00
bobloy
a1a44bf1cc
[Downloader] Hide [p]cog reinstallreqs (#4590) 2020-11-11 16:39:33 +01:00
jack1142
85afe19455
Bump black to 20.8b1 (and reformat) (#4371)
* Bump black version

* Reformat with black
2020-08-29 19:12:28 +02:00
jack1142
929fd04613
EUD things for Downloader (#4169)
* Initial commit

* Send pagified as with other Downloader's things
2020-08-17 01:27:46 +02:00
jack1142
c673bb0979
Fix the errors related to installed module having invalid commit data (#4086) 2020-08-05 19:35:57 +01:00
Michael H
c0b1e50a5f
Begin work on a data request API (#4045)
[Core] Data Deletion And Disclosure APIs

 - Adds a Data Deletion API
   - Deletion comes in a few forms based on who is requesting
   - Deletion must be handled by 3rd party
 - Adds a Data Collection Disclosure Command
   - Provides a dynamically generated statement from 3rd party
   extensions
 - Modifies the always available commands to be cog compatible
   - Also prevents them from being unloaded accidentally
2020-08-03 15:09:07 +02:00
jack1142
326ae76fe0
Fix the error for empty author list in [p]findcog (#4042) 2020-07-10 21:37:41 +01:00
jack1142
b49b53934d
Update deprecation warnings (#3608)
* Make deprecation notice specify minor release based on soonest date

* Stop specifying a specific release in shared libs deprecation notice

* Add actual deprecation warning for `APIToken` (OMG, this is so cool)

* Add dates (2020-08-05 for all)

* address review

* improve consistency

* Add __dir__ and show APIToken in docs (or maybe I want to annoy Flame)

* fix module name when importing non-existent name from parent package

* Fix stack level used by depr warn in `redbot.core.commands`
2020-06-22 03:25:33 +02:00
Vexed
d2de3c109a
[Downloader] Differentiate core and local cogs in [p]findcog (#3969) 2020-06-21 17:59:52 +01:00
Vexed
1cf8308d03
[Downloader] Embed version of findcog (#3965) 2020-06-18 21:37:46 +01:00
jack1142
a64c28aa44
Fix unnecessary typing before running commands in Downloader (#3964) 2020-06-18 15:47:12 +02:00
aikaterna
35365a7154
[Downloader] Add command to list pinned cogs (#3974) 2020-06-18 15:43:59 +02:00
Vexed01
332bcae24f Review
* Remove always
  - and consequently reorganise the words
* Add "one or more"
* Fix spelling of creator
  - changed from creater
2020-06-05 19:47:45 +01:00
Vexed01
049f23071c hmm actually no (undo) 2020-05-31 10:18:58 +01:00
Vexed01
e6c46bf4da add cog board link 2020-05-31 09:21:34 +01:00
Vexed01
219586d55d wording changes 2020-05-30 19:57:34 +01:00
Vexed01
ff46ca546d add class docstring to downloader
idk what to say rly
um hi all nice to be back after about 6 months
pls no hate my PRs
apoligies if i get in the way
if you read this far then you deserve an achievement um i dunno what err how about the achievement of unboredness
2020-05-30 17:19:54 +01:00
Draper
f59e77002b
Optimize config calls in few places (#3766)
* Just a tiny PR improving config call in a lot of places (Specially events and Help)

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>

* missed this one

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>

* welp

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>

* welp

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>

* welp

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>

* jack

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>

* Update redbot/cogs/mod/kickban.py

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

* jack

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2020-04-20 19:29:36 +02:00
Draper
e4018ec677
Normalize names of attributes with Config instances (#3765)
* Lets normalize how we name config attributes across the bot.

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>

* ....

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>

* nothing to see here

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>
2020-04-20 19:12:57 +02:00
jack1142
41c2b76d8d
Make [p]cog checkforupdates indicate when cog can't be updated on current Red/Python version 2020-03-28 15:53:10 +01:00
Stonedestroyer
287edb755d
Fix misleading error appearing when repo name is already taken (#3695)
* Error string change

* String
2020-03-26 13:26:05 +01:00
jack1142
eebea59fe3
Remove usage of loop arg in calls to start_adding_reactions (#3644)
* fix stacklevels of warnings

* stop using loop arg when calling start_adding_reactions

* [Audio] Stop using loop arg when calling start_adding_reactions
2020-03-20 20:44:57 +01:00
jack1142
5074f2dbab
Improve error message for OSError in [p]repo add (#3656)
* Update downloader.py

* Update downloader.py
2020-03-20 20:40:59 +01:00
jack1142
eedec4ff02
fix: use clean prefix in code blocks (#3591) 2020-02-28 21:23:13 +01:00
jack1142
4e4420af2e
Replace [p] with clean prefix in install messages (#3592) 2020-02-28 21:17:45 +01:00
jack1142
eff1014911
Add logging for unexpected OSError in [p]repo add (#3558)
* Update downloader.py

* Update downloader.py

Co-authored-by: Draper <27962761+Drapersniper@users.noreply.github.com>
2020-02-17 11:57:04 +00:00
Michael H
00cf395483
Handle deprecations in asyncio (#3509)
* passing loop to certain things was deprecated. additionally, `asyncio.get_event_loop()` is being deprecated

* awesome, checks are functioning as intended

* fun with fixtures

* we can just stop misuing that anyhow

* Update redbot/pytest/downloader.py

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2020-02-05 17:16:13 -05:00
jack1142
068585379a docs: deprecation of shared libraries has been postponed to 3.4 (#3449) 2020-01-26 12:16:44 -05:00
jack1142
fc5fc08962 [Downloader] Log errors from initialization task (#3444)
* Update downloader.py

* Create 3444.misc.rst

* enhance(downloader): don't type infinitely on init error

* fix(downloader): unindent `_ready_raised` check

* Update downloader.py
2020-01-26 12:16:13 -05:00
jack1142
2a38777379 [Downloader] Do the initialization in task to avoid timeout on bot startup (#3440)
* enhance(downloader): run init in task

* chore(changelog): add towncrier entry

* fix: address review
2020-01-24 12:38:42 -05:00
jack1142
67fbcb1b4a enhance(downloader): pagify any output that might be too long (#3388) 2020-01-17 04:44:10 -05:00
jack1142
cb49c5d420 [Downloader] Improve partial-uninstall message in [p]cog uninstall (#3343)
* Update downloader.py

* Let's use more of Flame's suggestions.

Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>

Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>
2020-01-12 18:21:00 -05:00
jack1142
af859aa755 [Downloader] Move author key handling to RepoJSONMixin, fix NameError (#3285)
* Update downloader.py

* Update json_mixins.py

* Update installable.py

* changelog pt 1

* changelog pt2

* edit of changelog pt1

* edit of changelog pt 2 (last commit before review)

* Kidding, this is the last one before review.
2020-01-08 13:08:55 -05:00
jack1142
d3c97eedfe [Downloader] Fix AttributeError in [p]findcog for cogs that weren't installed through Downloader (#3278)
* Update downloader.py

* Create 3278.misc.rst
2020-01-06 16:48:43 -05:00
jack1142
474bb0904e [Core, Downloader] Clear lib folder on minor Python version change, add [p]cog reinstallreqs command (#3274)
* feat(downloader): add `[p]cog reinstallreqs` command

* enhance: clear lib folder on minor Python version change

* chore(changelog): add towncrier entries

* enhance: warn user about detected change in OS or arch

* enhance: use actual prefix instead of `[p]`

* Whoops...

Co-Authored-By: Michael H <michael@michaelhall.tech>

* enhance: wrap message sending in try except

Co-authored-by: Michael H <michael@michaelhall.tech>
2020-01-05 19:21:49 -05:00
jack1142
bc90f5186a [Downloader] Actually use disabled key in updates (#3203)
* fix(downloader): actually use disabled key in updates

* chore(changelog): add towncrier entry
2020-01-02 08:49:31 -05:00
jack1142
f9211ff50f [Downloader] Fix UnboundLocalError in cog update that happened when cogs were already up-to-date. (#3230)
* Update downloader.py

* Create 3229.misc.rst
2019-12-27 18:53:38 -05:00
jack1142
de229f63fe [Downloader] Add more information to [p]repo info, [p]cog info and [p]findcog (#3225)
* Update downloader.py

* Update downloader.py

* Update downloader.py

* Create 3225.enhance.1.rst

* Create 3225.enhance.2.rst

* Create 3225.enhance.3.rst

* Update downloader.py

* Style fix, ready for review
2019-12-27 17:14:04 -05:00
jack1142
b457f8d1c1 [Core] Add deprecation warnings about removal of shared libraries. (#3106)
* feat: add deprecation warning when importing shared libs

* enhance(downloader): add shared libs deprecation warns

* enhance: add deprecation warning when (re)loading cogs

* docs(downloader): add deprecation note about shared libs

* chore(changelog): add towncrier entries

* style: split long tuple unpacks in multiple lines

* fix: argument to `humanize_list` has to be a sequence
2019-12-20 02:06:53 -05:00
jack1142
988536f96b [Downloader] Possible solution for "partial" unload of cog in [p]cog uninstall (#3180)
* Update downloader.py

* Create 3180.bugfix.rst

* Rename 3180.bugfix.rst to 3179.bugfix.rst

* Update redbot/cogs/downloader/downloader.py

Co-Authored-By: Michael H <michael@michaelhall.tech>
2019-12-11 18:28:52 -05:00
Tomas S
064d97f87b [Downloader] Catch and handle erorr in update_all when target repository/branch is missing (#3080)
* [Downloader] Catch and handle erorr in update_all when target repository/branch is removed from remote

* Rewrite fix, remove ctx from repo_manager, edit docstring, add annotations

* Text formatting

* Group failed repo messages into padded table, catch single updated repo fails

* Error catching v2; repo_manager design change

* Docstrings, typos and changelog

* Add Optional to update_repos annotatition

* Wrong logic

* Clear-er log message.

* add format_failed_repos, change _repo_update for failed messages

* Merge cog updating with fail repo logic; Filter out failed repos

* Merge cog updating with fail repo logic; Cog updating logic shuffled to support sending fails at the end

* Docstring typo

* format_failed_repos - proper docstring

* repo_manager.update_repos argument name fix

* downloader._cog_checkforupdates added missed failed message

* downloader._cog_update_logic place back return on some errors

* Purge unused stuff from downloader._repo_update

* downloader._cog_update_logic Change exception catching

* _cog_update_logic purging obsolete

* Remove obsolete 'message' from _cog_checkforupdates

* Fix forgotten ctx.send

* Wording

* Removed obsolete 'message'

* Fix wrong type hint in , update docstring

* repo update logic fix

* format_failed_repos type hint and docstring repair

* Extend _get_cogs_to_check with 'update_repos'

* Fix type mangling in _get_cogs_to_check

* fix: typo

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

* _repo_update; Added single repo up-to-date message
2019-12-08 17:59:53 -05:00
jack1142
9a051ef2c6 [Downloader] Fix [p]findcog not working with different levels of imports (#3178)
* Update downloader.py

* Create 3177.bugfix.rst
2019-12-08 17:58:43 -05:00
Flame442
d07e718ab8 Fixes errors on repo add from empty string values for install_msg (#3153)
* Fixes errors on repo add from empty string values for `install_msg`

* Create 3153.bugfix.rst
2019-12-02 11:41:28 -05:00
jack1142
8a90996b36 [Downloader] Add Repo.clean_url and use it in [p]findcog (#3129)
* enhance(downloader): add `Repo.clean_url` and use it in `[p]findcog`

* chore(changelog): add towncrier entries
2019-11-17 10:25:15 -05:00
jack1142
e2c8b11008 [V3 Downloader] Revision tracking (#2571)
* feat(downloader): Install cog from specific commit in repo (initial commit)

- Repo and Installable have commit property now
- New class inheriting from Installable -
InstalledCog (old one from converters.py removed)
- New Repo.checkout() method, which is also async ctx manager
ref #2527

* fix(downloader): Keep information about repo's branch in config

- This is needed to make sure that repo can go back from detached state in some rare unexpected
cases
- current branch is determined by `git symbolic-ref` now as this command errors for detached
HEAD

* feat(downloader): Update repo without cogs, update single cog

The most important part of issue #2527 has been added here
- `[p]repo update` command added
- new conf format - nested dictionary repo_name->cog_name->cog_json
  installed libraries are now kept in conf too
  - `InstalledCog` renamed to `InstalledModule` - installed libraries use this class
  - `Downloader.installed_libraries()` and `Downloader.installed_modules()` added
  - `Downloader._add_to_installed()` and `Downloader._remove_from_installed()`
    now accept list of modules, of both cogs and libraries
- `[p]cog install` tells about fails of copying cog and installing shared libraries
- `[p]cog update` will truly update only chosen cogs (if provided) or cogs that need update
  - pinned cogs aren't checked
  - before update, repos are updated
  - to determine if update is needed `Repo.get_modified_modules()` is used
- `[p]cog pin` and `[p]cog unpin` commands for pinning/unpinning cogs added
- `Repo.checkout()` allows to choose ctx manager exit's checkout revision
- `Repo.install_cog()` returns `InstalledModule` now and raises CopyingError (maybe breaking?)
- `Repo.install_libraries()` returns 2-tuple of installed and failed libraries (maybe breaking?)
- `RepoManager.get_all_cogs()` added, which returns cogs from all repos
- `RepoManager.repos` property added, which contains tuple of `Repo`

* test(downloader): Repo.current_branch() throws an exception, when branch can't be determined

* style(downloader): rename _add_to_installed to _save_to_installed

This method is used for both adding and updating existing modules in Config

* refactor(downloader): add ctx.typing() for few commands

`[p]cog install` is nested hell, can't wait for moving install logic to separate method

* fix(downloader): refactor and fix `set` usage

* perf(downloader): update commits for ALL checked modules to omit diffs next time

This will also disable running git diff for cogs that have the same commit as the latest one

* style(downloader): few style improvements

- use of mutable object in method definition
- make Repo._get_full_sha1() public method
- too long
line
- don't use len to check if sequence is empty

* feat(downloader): add `[p]cog updateallfromrepos` and `[p]cog updatetoversion` commands

- moved cog update logic into `Downloader._cog_update_logic()` (lack of better name)
  - splitted
whole cog update process into smaller methods
  - might still need some improvements
- added new
methods to `Repo` class:
  - `is_on_branch()` to check if repo is currently checked out to branch

- `is_ancestor()` to check if one commit is ancestor of the other
- fix for
`Downloader._available_updates()` behaviour
broken by commit
5755ab08ba67556b3863e907c6f44d80f4f13d88

* feat(downloader): try to find last commit where module is still present

Enhancements:
- `Installable` now has `repo` attribute containing repo object or `None` if repo is
missing
- `Downloader._install_cogs()` and `Downloader._reinstall_libraries()` are able to install
modules from different commits of repo
- `Repo.checkout()` as ctx manager will now exit to commit
which was active before checking out
- unification of `rev` and `hash` terms:
All function
parameters are explicitly called `hash`, if it can only be commit's full sha1 hash or `rev` if it
can be anything that names a commit object, see
[link](https://git-scm.com/docs/git-rev-parse#_specifying_revisions)
- new
`Repo.get_last_module_occurence()` method, which gets module's Installable from last commit in which
it still occurs

* docs(downloader): Add basic description for `InstalledModule`

* fix(downloader): cog ignored during updates if its commit was missing

After config format update, commit string is empty until update and when such cog was checked and it
wasn't available in repo anymore, it was ignored

* refactor(downloader): Installing cogs from specific rev will pin them

* perf(downloader): Don't checkout when current commit equals target hash

- changes to `Repo.checkout()`:
  - `exit_to_rev` is now keyword only argument
  - added
`force_checkout` to force checkout even if `Repo.commit` value is the same as target hash

* refactor(downloader): Repo._run() stderr is redirected to debug log now

- added two keyword arguments:
  - `valid_exit_codes` which specifies valid exit codes, used to
determine if stderr should be sent as debug or error level in logging
  - `debug_only` which
specifies if stderr can be sent only as debug level in logging

* style(downloader): stop using `set` as arg name in `_load_repos()`

* feat(downloader): pass multiple cogs to `[p]cog (un)pin`

* refactor(downloader): accept module name instead of instance, fix spelling

* style(downloader): few small style changes

* fix(downloader): add type annotations + fixes based on them

- fix wrong type annotations and add a lot of new ones
- add checks for `Installable.repo` being `None`
- fix wrong return type in `Downloader._install_requirements`
- show repo names correctly when updating all repos
- fix error when some requirement fails to install

BREAKING CHANGE:
- type of `Repo.available_modules` is now consistent (always `tuple`)

* tests: use same event loop policy as in Red's code

* enhance(downloader): fully handle ambiguous revisions

* build(deps): add pytest-mock dependency to tests extra

* fix(downloader): minor fixes

* feat(downloader): add tool for editing Downloader's test repo

This script aims to help update the human-readable version of repo
used for git integration tests in ``redbot/tests/downloader_testrepo.export``
by exporting/importing it in/from provided directory.

Note
----
Editing `downloader_git_test_repo.export` file manually is strongly discouraged,
especially editing any part of commit directives as that causes a change in the commit's hash.
Another problem devs could encounter when trying to manually edit that file
are editors that will use CRLF instead of LF for new line character(s) and therefore break it.

I also used `.gitattributes` to prevent autocrlf from breaking testrepo.

Also, if Git ever changes currently used SHA-1 to SHA-256 we will have to
update old hashes with new ones. But it's a small drawback,
when we can have human-readable version of repo.

Known limitations
-----------------
``git fast-export`` exports commits without GPG signs so this script disables it in repo's config.
This also means devs shouldn't use ``--gpg-sign`` flag in ``git commit`` within the test repo.

* tests(downloader): add git tests and test repo for them

Also added Markdown file that is even more clear than export file
on what the test repo contains.
This is manually created but can be automated on later date.

* test(downloader): add more tests related to RepoManager

These tests use expected output that is already guaranteed by git tests.

* chore(CODEOWNERS): add jack1142 to Downloader's folders

I know this doesn't actually give any benefit to people that don't have
write permission to the repo but I saw other big fella devs doing this,
so I think this might be advisable.

* enhance(downloader): allow easy schema updates in future

* enhance(downloader): more typing fixes, add comments for clarity

* feat(downloader): add python and bot version check to update process

follow-up on #2605, this commit fully fixes #1866

* chore(changelog): add towncrier entries

* fix(downloader): use `*args` instead of `commands.Greedy`

* fix(downloader): hot-reload issue - `InstallableType` now inherits from `IntEnum`

There's desync of `InstallableType` class types due to hot-reload
and `IntEnum` allows for equality check between different types

* enhance(downloader): ensure there's no cog with same name installed

should fix #2927

* fix(downloader): last few changes before marking as ready for review
2019-11-07 20:36:16 -05:00
jack1142
3b0fa0c05d [Core/Downloader] Add 3rd-party lib folder to sys.path before loading cogs (#3062)
* fix(core,downloader): add lib folder to sys.path before loading cogs

* chore(changelog): add towncrier entry

* fix(core): always append 3rd-party lib path to the end of `sys.path`
2019-10-21 22:43:00 -04:00
Flame442
9b60816ebd [Downloader] Catch OSErrors from invalid repo names (#3029)
* [Downloader] Ensure repo names only contain the characters stated

* Create 2827.bugfix.rst

* [Downloader] Catch OSErrors from invalid filenames

* Update 2827.bugfix.rst

* Style

* do the thing again

* Update 2827.bugfix.rst
2019-10-04 22:19:00 -04:00
DiscordLiz
05eba603a5 Prevent error on empty install message. (#3024)
* Prevent error on empty install message.

* Create 3024.bugfix.rst
2019-10-02 20:38:52 -04:00
Michael H
25614620db
More privatization, and some error helpers (#2976)
* More privatization, and some error helpers

This makes a lot more things private. Continued from #2967, fixes #2984
Adds public methods for various things.

Below is a brief summary of things available elsewhere, though this
particular set of changes may warrant a detailed section in the release notes.

 - bot.db.locale -> redbot.core.i18n.get_locale
   - Note: This one already existed.
 - bot.db.help -> redbot.core.commands.help.HelpSettings
 - bot db whitelist/blaclist? -> bot.allowed_by_whitelist_blacklist
   - This has also been made a single cannonical function for this
   purpose including check usage
 - bot color? -> bot.get_embed_color/bot.get_embed_colour
 - bot.id.api_tokens? ->

   - bot.get_shared_api_tokens
   - bot.set_shared_api_tokens
   - bot.remove_shared_api_tokens

 -bot.db.prefix -> bot.get_valid_prefixes
   - (Note: This is a wrapper around bot.get_prefix)

 Other changes include
  - removing `bot.counter` as it was never used anywhere
  - Adding properties with helpful error messages for moved and renamed
  things
  - making bot.uptime a property with an error on set
  - adding a migration to the bot config for shared_api_tokens

* Remove overly encompassing message redaction, eval is a risk, dont run in dev if you cant manage it

* address Flame's feedback

* rephrase example

* changelog extras

* You saw nothing
2019-09-26 12:55:05 -04:00