-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Per directory yaml #1759
Per directory yaml #1759
Conversation
How would the sample .guake.yml file look like? And where could it be located? |
@zeusintuivo right now I guess it could be extended or modified. In my own machine, I have now some directories I frequently used with
and when I get into that directory the tab has "backed" as title, it's very simple at the moment. |
I see, this is an original idea. It could be even better if could perfom custom commands. Like set node version or rbenv or rvm or php version. Perhaps have a command line execution section. And also following that topic a autostart section. Something that would only run once vs command line execution that would run every time you go in the folder? |
I am glad you like it ;) I am honestly just interested in the title. I am aware more things are possible as you said, but some seem a bit dangerous to me, or at least it seems it should the responsibility of a different component, like .bashrc or something like that. Also, the API used for the proof-of-concept seems a bit poor to me honestly, and I would be afraid of adding too many options. Like is ok to set the name of the label twice in less than a second, but you could easily get into problems if you run a large command. I would leave it just as a way to configure Guake on a per-directory basis. |
4519840
to
7b5eced
Compare
Closing old PR |
Hi, is there a way to reopen this and consider merging this feature? |
You can reopen but please update the pull request description and the Reno chunk |
Going back through issues, found this through an old issue and it looks like it could be nice, reopening and will check later. For now, you may need to rebase your branch to pass test cases. |
Alright, I've gone and done some quick fixing up with the build errors so now we can look at the content of this. For one, we're going to need some docs written so people can actually know how to format the yaml files |
can you confirm if this PR is still ok? |
Pull request has good stuff but needs a little bit more written before it's a feature to add. We need docs so that people can know that this is a thing that guake will look for, maybe some nice controls in the UI for creating these files and then some testing. |
I added a small explanation with an example in the Feature section of the documentation. I imagine we could use this file for more than just the title. So far I have been using this for over a year and I love it, it makes it really easy to navigate my tabs, though I only get lost when I am in a remote machine via ssh. I haven't thought too much about that case anyway or similar: opening another shell from the original shell. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, tested the branch and it works as expected, so going in a little more in depth now. First order of business, the checks seem to be failing again, so those need to be dealt with. Some structural things as well for potential future development of the file as well.
guake/guake_app.py
Outdated
def compute_tab_title(self, vte): | ||
"""Compute the tab title""" | ||
|
||
guake_yml = self.read_current_guake_yaml(vte) | ||
if guake_yml is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can move these checks into the yaml read function? So if there's more added to the yaml file in the future, there's a bit less boilerplate checking that needs to be rewritten each time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the is not None
internally to the read_current_guake_yaml
method. That method is returning a dictionary with the file's content, not just a string with the title, so a minimal check is still required here. I did this thinking that the .guake.yml
file might contain more than a title.
Great, I added the encoding. I am not sure how much effor to put on checking in the Also, I am using the extension I am happy to hear also if adding typings is in the future plans, fro vte in particular I guess I need to add an import on Vte and the vte argument is a 'Vte.Terminal' right? Best. |
The merge from master seems to be failing checks, I'll fix that real quick. |
6848181
to
a84b557
Compare
I would like to have description of this PR update at the OP description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add option to reduce disk load, and audit yaml.safe_load to prevent arbitrary code
guake/guake_app.py
Outdated
@@ -1070,9 +1071,37 @@ def recompute_tabs_titles(self): | |||
page_num = self.get_notebook().page_num(terminal.get_parent()) | |||
self.get_notebook().rename_page(page_num, self.compute_tab_title(terminal), False) | |||
|
|||
def read_current_guake_yaml(self, vte) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
read_current_directory_guake_yaml()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or load_current..., more suitable for describing what is has done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed for load_cwd_guake_yaml
seems better to me since is shorter.
guake/guake_app.py
Outdated
try: | ||
if guake_yaml.is_file(): | ||
with guake_yaml.open(encoding="utf-8") as fd: | ||
content = yaml.safe_load(fd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should audit yaml.safe_load()
as this could be a point to include arbitrary code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
safe_load() should be the safe version of load()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with David. I am not planning in going deep into the yaml implementation to check if safe_load
is as safe as they advertise it.
guake/guake_app.py
Outdated
def compute_tab_title(self, vte): | ||
"""Compute the tab title""" | ||
|
||
guake_yml = self.read_current_guake_yaml(vte) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add config option (enable, disable) to reduce reading from disk.
I still have to add a flag in the configuration to activate reading from this file. I will try to finish that during the week. Regarding caching the content to prevent unnecessary reads, I honestly would first implement a very simple |
Yeah sure that'll probably be fine, generally should use monotonic() instead of time() though for the safety. |
Back because build failed. For future reference, you can just run |
961853b
to
aa147f1
Compare
aa147f1
to
557bcf2
Compare
I added an options in prefs and a way to cache the content of the yaml files and prevent reloading too often. I honestly don't like to have the two properties _guake_yml and _guake_yml_load_monotonic but this is a simple solution I guess. |
CI failing, you might need to rebase your branch onto latest git to resolve the weird dependency thing because I'm not seeing this issue crop up in any of the other active PRs. Looking at the things deepsource is complaining about, you can ignore the second one because it doesn't have anything to do with your changes but this one is relevant. |
…guake.yml file more than once per second
bf12a5e
to
d00d4d1
Compare
Hi @Davidy22 I did the rebase to master, but the error is still there. I honestly don't know what's the problem since |
The PR is now "ok" according to the last run. The tests are not passing in th CI, but they pass on my machine. Regarding the code, I was planning to just add a FileManager class in utils.py to handle the cache for file content instead of the two properties in the Guake class. What do you thik about that? |
Oh, I see you added a pyyaml line to the pipfile, so that probably changes the dependency graph and I suspect that's where the issue is coming from. You can do a |
8a9baed
to
83ae070
Compare
83ae070
to
1da807b
Compare
7a5942e
to
06f9179
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we finally got all checks passing, looks good and works fine, merging.
The present requests add the option of reading a yaml-formatted file in the current working directory loading the title of a tab.