turbogears / gearbox Goto Github PK
View Code? Open in Web Editor NEWCommand line toolkit born as a paster command replacement for the TurboGears2 web framework
License: MIT License
Command line toolkit born as a paster command replacement for the TurboGears2 web framework
License: MIT License
Some notes from the porting - it could perhaps be the missing(?) documentation
for migrating from paster to gearbox:
Replace paster
summary = 'yada yada'
with the first line of the docstring of the Command class ... or override
get_description.
Note: All newlines in the docstring will be collapsed and mangle the long help
text.
Grouping of commands is not possible. Standard commands (for development) can't
be customized under the same name or hidden. (Like for paster, the conceptual
model also assumes that the sub-command naming is namespaced so commands from
other packages won't conflict.)
The usage help is fully automated from the declared options.
For all deprecated Commands, replace paster
hidden = True
with gearbox
deprecated = True
Note: config_file, takes_config_file, min_args and max_args are not available /
relevant.
The gearbox parser is customized by overriding get_parser - there is nothing
like paster update_parser.
Gearbox is using argparse instead of optparse ... but argparse add_argument is
mostly backwards compatible with optparse add_option.
Instead of overriding command or run as in paster, override take_action in
gearbox. The parsed arguments are passed to take_action, not available on the
command instance.
As Cliff provided its own logging configuration and serve command did too the two pretty much messed one with the other.
Now that cliff has been removed it would pretty much make sense to merge the two logging configuration, let gearbox load logging configuration from a file and have serve use gearbox configuration.
I'm using gearbox serve
command to deploy my app with paste deploy.
Does anyone have any launch.json
template to debug a TG2 application with gearbox in vscode?
Thank you
Note: 'gearbox' without parameters will crash - specify '-h' to get started testing.
Because log missed messages which is created at app initilization.
# pip install gearbox==0.2.1
Collecting gearbox==0.2.1
ERROR: Could not find a version that satisfies the requirement gearbox==0.2.1 (from versions: 0.0.1a0, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.1.0, 0.1.1, 0.2.0)
ERROR: No matching distribution found for gearbox==0.2.1
Tag 0.2.1 fixes multi-threaded server on python 3, it will be useful to have it released.
It's too old information in setup.cfg that metadata section has version = 0.0.1.
And bad formated dist-requires causes error during processing dist-info.
I think that should be removed from setup.cfg.
gearbox serve patches stdout/stderr to be an object of class LazyWriter, which only opens the file when something is written. Is this only to avoid an empty log file in case an application never actually writes anything?
In the Kallithea project, a problem was reported [1] which is actually not related to Kallithea itself but by the interaction between Mercurial code and gearbox Lazywriter. Mercurial wants to access the 'buffer' property of stdout/stderr, but Lazywriter does not implement it.
In order to work around it from Kallithea, we have to do something like [2] which is not very nice.
A possible alternative is that LazyWriter actually forwards any attribute access it doesn't know about to the real file object (but in this case it should actually open the file).
Another alternative is to just stop using LazyWriter. If the only goal is to not create an empty log file when the app happens to be silent, then I don't consider it as having much value. Many UNIX applications that accept a log file path as argument will create the file regardless of output.
Maybe other solutions exist too.
[1] https://bitbucket.org/conservancy/kallithea/issues/371
[2] https://kallithea-scm.org/repos/kallithea-incoming/changeset/ba656cdb88eae618beb3d6b83b2c14584b9233d8
Paster BadCommand is not available and must be handled manually, terminating
with sys.exit(1).
In Paster raising an exception named BadCommand
allowed to quit with an error message ( see https://github.com/Pylons/pylons/blob/master/pylons/commands.py#L107 ).
This is no longer possible in gearbox and requires to call sys.exit
which abruptly quits the application. raising BadCommand and trapping it into gearbox as a signal that you shoudl gracefully quit was a better pattern.
By default it should quit with a 1
exit code, but it should be possible to provide a custom one when raising the BadComand
exception.
'gearbox serve --daemon' will stuck when start it for a moment
'gearbox serve --status' seems well,but get no response after a call
hello friends,
i'm happily using turbogears for ages, but realized with horror that all my development work,
including manager logins, went in the open http.
i took tg 2.3.7 for a new project, but this time i wish to begin development in a secure environment,
so i applied the included patch to allow working with ssl.
i'd thank you in advance if you could share my patch with the public.
alex
gearbox-ssl.zip
It is currently not documented that subcommands can be provided through subparsers
like https://github.com/TurboGears/tg2devtools/blob/development/devtools/gearbox/alembic_migrate.py does.
It is also not really easy to load the subcommands through extensions and gearbox should provide a facility for that.
Hi guys, could you ship a full text of the license along with the tarball? It makes linux distributions happy - there's no ambiguity.
Following the example setup on on the TurboGears website, for wiki20.
https://turbogears.readthedocs.io/en/development/turbogears/wiki20.html#wiki20
I've tested this in a python 3.9.9 virtualenv
pip install tg.devtools
gearbox quickstart wiki20
pip install -e .
pip freeze
)gearbox setup-app
The following error appears (edited slightly to remove my computer paths)
21:17:52,209 ERROR [gearbox] 'PathDistribution' object has no attribute 'get_metadata_lines'
Traceback (most recent call last):
File "~/.pyenv/versions/3.9.9/envs/tg-gearbox-pastedeploy-test/lib/python3.9/site-packages/gearbox/main.py", line 172, in _run_subcommand
return cmd.run(parsed_args)
File "~.pyenv/versions/3.9.9/envs/tg-gearbox-pastedeploy-test/lib/python3.9/site-packages/gearbox/command.py", line 31, in run
self.take_action(parsed_args)
File "~/.pyenv/versions/3.9.9/envs/tg-gearbox-pastedeploy-test/lib/python3.9/site-packages/gearbox/commands/setup_app.py", line 53, in take_action
self._setup_config(dist, config_file, section, {}, verbosity=self.app.options.verbose_level)
File "~/.pyenv/versions/3.9.9/envs/tg-gearbox-pastedeploy-test/lib/python3.9/site-packages/gearbox/commands/setup_app.py", line 70, in _setup_config
modules = [line.strip() for line in dist.get_metadata_lines('top_level.txt')
AttributeError: 'PathDistribution' object has no attribute 'get_metadata_lines'
Installing PasteDeploy==2.1.1
, will then allow gearbox setup-app
to run.
(Note this is also an issue with 3.0)
Apologies if this is actually an issue with PasteDeploy, I could not tell if this due to the use of the library, or the library itself. The release notes don't seem to mention this being removed.
Hey folks, I've done a lot of work in Pyramid's pserve (which of course is derived from PasteScript -
the same code as gearbox's serve command) to make the reloader smarter. One major feature is that it does not crash when your code fails to start, so you do not need to continually restart it. The library that does this was pulled out into a framework-agnostic entity called hupper.
http://docs.pylonsproject.org/projects/hupper/en/latest/
Anyway, I just wanted to bring it to your attention incase you are interested in using it for an improved --reload
experience.
ATM, only gearbox help quickstart
would bring up the help for the quickstart command, but IMO using gearbox quickstart -h
or gearbox quickstart --help
would be more intuitive (or if it at least told you where to look for the help text :D)
Steps to reproduce:
1 - create a project using the "gearbox quickstart"
2 - create a new module called mymod in the root dir project
3 - execute "pip install -e ."
4 - execute "gearbox setup-app -c development.ini"
After it you should see the bellow error:
root@4175eeb480ae:/myproj# gearbox setup-app -c development.ini
No module named 'mymod.websetup'
12:17:42,701 ERROR [gearbox] No module named 'mymod.websetup'
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/gearbox/main.py", line 172, in _run_subcommand
return cmd.run(parsed_args)
File "/usr/local/lib/python3.9/site-packages/gearbox/command.py", line 31, in run
self.take_action(parsed_args)
File "/usr/local/lib/python3.9/site-packages/gearbox/commands/setup_app.py", line 53, in take_action
self._setup_config(dist, config_file, section, {}, verbosity=self.app.options.verbose_level)
File "/usr/local/lib/python3.9/site-packages/gearbox/commands/setup_app.py", line 79, in _setup_config
mod = self._import_module(mod_name)
File "/usr/local/lib/python3.9/site-packages/gearbox/commands/setup_app.py", line 114, in _import_module
mod = __import__(s)
ModuleNotFoundError: No module named 'mymod.websetup'
This issue happens only on python 3.
With:
alembic==0.7.5.post2
Babel==1.3
backlash==0.0.7
Beaker==1.6.5.post1
cliff==1.10.1
cmd2==0.6.8
crank==0.7.2
decorator==3.4.2
FormEncode==1.3.0
gearbox==0.0.7
Genshi==0.7
Mako==1.0.1
MarkupSafe==0.23
PasteDeploy==1.5.2
pbr==0.10.8
prettytable==0.7.2
proyectos===0.1dev-r0
psycopg2==2.6
Pygments==2.0.2
pyparsing==2.0.3
pytz==2015.2
repoze.lru==0.6
repoze.who==2.2
six==1.9.0
speaklater==1.3
sprox==0.9.5
SQLAlchemy==0.9.9
stevedore==1.3.0
Tempita==0.5.2
tg.devtools==2.3.4
tgext.admin==0.6.4
tgext.crud==0.7.3
tgext.debugbar==0.2.4
transaction==1.4.3
TurboGears2==2.3.4
tw2.core==2.2.2
tw2.forms==2.2.2.1
WebOb==1.4
WebTest==1.4.3
zope.interface==4.1.2
zope.sqlalchemy==0.7.6
If you set as the manual says to enable multiple databases:
sqlalchemy.first.url = sqlite:///%(here)s/devdata.db
sqlalchemy.second.url = sqlite:///%(here)s/devdata2.db
you get with "gearbox setup-app --debug":
23:51:05,660 WARNI [py.warnings] /home/asarch/tg2dev/lib/python2.7/site-packages/tw2/core/validation.py:12: ImportWarning: Not importing directory '/home/asarch/tg2dev/lib/python2.7/site-packages/tw2/core/i18n': missing init.py
from .i18n import _
23:51:06,143 WARNI [py.warnings] /home/asarch/tg2dev/lib/python2.7/site-packages/sqlalchemy/dialects/init.py:35: SADeprecationWarning: The SQLAlchemy PostgreSQL dialect has been renamed from 'postgres' to 'postgresql'. The new URL format is postgresql[+driver]://:@/
module = import('sqlalchemy.dialects.%s' % (dialect, )).dialects
23:51:06,154 ERROR [gearbox] 'url'
Traceback (most recent call last):
File "/home/asarch/tg2dev/lib/python2.7/site-packages/cliff/app.py", line 303, in run_subcommand
result = cmd.run(parsed_args)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/cliff/command.py", line 53, in run
self.take_action(parsed_args)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/gearbox/commands/setup_app.py", line 53, in take_action
self._setup_config(dist, config_file, section, {}, verbosity=self.app.options.verbose_level)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/gearbox/commands/setup_app.py", line 93, in _setup_config
self._call_setup_app(mod.setup_app, filename, section, vars)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/gearbox/commands/setup_app.py", line 108, in _call_setup_app
func(None, conf, vars)
File "/home/asarch/tg2dev/proyectos/proyectos/websetup/init.py", line 17, in setup_app
load_environment(conf.global_conf, conf.local_conf)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/tg/configuration/app_config.py", line 794, in load_environment
self.setup_persistence()
File "/home/asarch/tg2dev/lib/python2.7/site-packages/tg/configuration/app_config.py", line 590, in setup_persistence
self.setup_sqlalchemy()
File "/home/asarch/tg2dev/proyectos/proyectos/config/app_cfg.py", line 23, in setup_sqlalchemy
engine = engine_from_config(config, 'sqlalchemy.')
File "/home/asarch/tg2dev/lib/python2.7/site-packages/sqlalchemy/engine/init.py", line 407, in engine_from_config
url = options.pop('url')
KeyError: 'url'
Running setup_app() from proyectos.websetup
Traceback (most recent call last):
File "/home/asarch/tg2dev/bin/gearbox", line 9, in
load_entry_point('gearbox==0.0.7', 'console_scripts', 'gearbox')()
File "/home/asarch/tg2dev/lib/python2.7/site-packages/gearbox/main.py", line 94, in main
return gearbox.run(args)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/cliff/app.py", line 238, in run
result = self.run_subcommand(remainder)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/cliff/app.py", line 303, in run_subcommand
result = cmd.run(parsed_args)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/cliff/command.py", line 53, in run
self.take_action(parsed_args)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/gearbox/commands/setup_app.py", line 53, in take_action
self._setup_config(dist, config_file, section, {}, verbosity=self.app.options.verbose_level)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/gearbox/commands/setup_app.py", line 93, in _setup_config
self._call_setup_app(mod.setup_app, filename, section, vars)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/gearbox/commands/setup_app.py", line 108, in _call_setup_app
func(None, conf, vars)
File "/home/asarch/tg2dev/proyectos/proyectos/websetup/init.py", line 17, in setup_app
load_environment(conf.global_conf, conf.local_conf)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/tg/configuration/app_config.py", line 794, in load_environment
self.setup_persistence()
File "/home/asarch/tg2dev/lib/python2.7/site-packages/tg/configuration/app_config.py", line 590, in setup_persistence
self.setup_sqlalchemy()
File "/home/asarch/tg2dev/proyectos/proyectos/config/app_cfg.py", line 23, in setup_sqlalchemy
engine = engine_from_config(config, 'sqlalchemy.')
File "/home/asarch/tg2dev/lib/python2.7/site-packages/sqlalchemy/engine/init.py", line 407, in engine_from_config
url = options.pop('url')
KeyError: 'url'
and if you just set the new url for the second database with:
sqlalchemy.url = sqlite:///%(here)s/devdata.db
sqlalchemy.second.url = sqlite:///%(here)s/devdata.db
you get with "gearbox setup-app --debug":
23:55:31,038 WARNI [py.warnings] /home/asarch/tg2dev/lib/python2.7/site-packages/tw2/core/validation.py:12: ImportWarning: Not importing directory '/home/asarch/tg2dev/lib/python2.7/site-packages/tw2/core/i18n': missing init.py
from .i18n import _
23:55:31,511 ERROR [gearbox] Invalid argument(s) 'second.url' sent to create_engine(), using configuration SQLiteDialect_pysqlite/NullPool/Engine. Please check that the keyword arguments are appropriate for this combination of components.
Traceback (most recent call last):
File "/home/asarch/tg2dev/lib/python2.7/site-packages/cliff/app.py", line 303, in run_subcommand
result = cmd.run(parsed_args)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/cliff/command.py", line 53, in run
self.take_action(parsed_args)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/gearbox/commands/setup_app.py", line 53, in take_action
self._setup_config(dist, config_file, section, {}, verbosity=self.app.options.verbose_level)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/gearbox/commands/setup_app.py", line 93, in _setup_config
self._call_setup_app(mod.setup_app, filename, section, vars)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/gearbox/commands/setup_app.py", line 108, in _call_setup_app
func(None, conf, vars)
File "/home/asarch/tg2dev/proyectos/proyectos/websetup/init.py", line 17, in setup_app
load_environment(conf.global_conf, conf.local_conf)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/tg/configuration/app_config.py", line 794, in load_environment
self.setup_persistence()
File "/home/asarch/tg2dev/lib/python2.7/site-packages/tg/configuration/app_config.py", line 590, in setup_persistence
self.setup_sqlalchemy()
File "/home/asarch/tg2dev/proyectos/proyectos/config/app_cfg.py", line 23, in setup_sqlalchemy
engine = engine_from_config(config, 'sqlalchemy.')
File "/home/asarch/tg2dev/lib/python2.7/site-packages/sqlalchemy/engine/init.py", line 408, in engine_from_config
return create_engine(url, *_options)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/sqlalchemy/engine/init.py", line 386, in create_engine
return strategy.create(_args, *_kwargs)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 145, in create
engineclass.name))
TypeError: Invalid argument(s) 'second.url' sent to create_engine(), using configuration SQLiteDialect_pysqlite/NullPool/Engine. Please check that the keyword arguments are appropriate for this combination of components.
Running setup_app() from proyectos.websetup
Traceback (most recent call last):
File "/home/asarch/tg2dev/bin/gearbox", line 9, in
load_entry_point('gearbox==0.0.7', 'console_scripts', 'gearbox')()
File "/home/asarch/tg2dev/lib/python2.7/site-packages/gearbox/main.py", line 94, in main
return gearbox.run(args)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/cliff/app.py", line 238, in run
result = self.run_subcommand(remainder)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/cliff/app.py", line 303, in run_subcommand
result = cmd.run(parsed_args)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/cliff/command.py", line 53, in run
self.take_action(parsed_args)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/gearbox/commands/setup_app.py", line 53, in take_action
self._setup_config(dist, config_file, section, {}, verbosity=self.app.options.verbose_level)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/gearbox/commands/setup_app.py", line 93, in _setup_config
self._call_setup_app(mod.setup_app, filename, section, vars)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/gearbox/commands/setup_app.py", line 108, in _call_setup_app
func(None, conf, vars)
File "/home/asarch/tg2dev/proyectos/proyectos/websetup/init.py", line 17, in setup_app
load_environment(conf.global_conf, conf.local_conf)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/tg/configuration/app_config.py", line 794, in load_environment
self.setup_persistence()
File "/home/asarch/tg2dev/lib/python2.7/site-packages/tg/configuration/app_config.py", line 590, in setup_persistence
self.setup_sqlalchemy()
File "/home/asarch/tg2dev/proyectos/proyectos/config/app_cfg.py", line 23, in setup_sqlalchemy
engine = engine_from_config(config, 'sqlalchemy.')
File "/home/asarch/tg2dev/lib/python2.7/site-packages/sqlalchemy/engine/init.py", line 408, in engine_from_config
return create_engine(url, *_options)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/sqlalchemy/engine/init.py", line 386, in create_engine
return strategy.create(_args, *_kwargs)
File "/home/asarch/tg2dev/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 145, in create
engineclass.name))
TypeError: Invalid argument(s) 'second.url' sent to create_engine(), using configuration SQLiteDialect_pysqlite/NullPool/Engine. Please check that the keyword arguments are appropriate for this combination of components.
Related to #14, we've written a new library called plaster for abstracting the config format away from Pyramid so that people can write their own custom formats. This can be updated in a bw-compatible way by depending on plaster_pastedeploy. Plaster can also be used for other purposes like sharing a config file with your message queue that is written as a gearbox subcommand or standalone.
http://docs.pylonsproject.org/projects/plaster/en/latest/
Again, I just wanted to bring it to your attention and am interested in your thoughts on using it.
Crashes with a file not found error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.