Skip to content
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

User Sources #78

Open
bluss opened this issue Mar 13, 2017 · 17 comments
Open

User Sources #78

bluss opened this issue Mar 13, 2017 · 17 comments

Comments

@bluss
Copy link
Member

bluss commented Mar 13, 2017

Allow users to extend the catalog by using shell scripts (or other programs) that produce textual output. In this way they act like indexers. A User source plugin will parse the output of each command into Leaves of the correct type.

@SanskritFritz
Copy link
Contributor

Great idea!

@khurshid-alam
Copy link

Wonderful idea.

@bluss
Copy link
Member Author

bluss commented Mar 14, 2017

Cool. Do you have any wishes for the format?

Supporting a plain list of files (one file per line) is clear candidate.

What I would reach for first is JSON, in a prototype I have one JSON object (dict) per line. JSON is good because it is typed, and we could use this to have it be entirely extensible (you could create leaves of any loaded plugin that whose leaves support a protocol for creating them from a dict from JSON).

@khurshid-alam
Copy link

Yes JSON is nice.

you could create leaves of any loaded plugin that whose leaves support a protocol for creating them from a dict from JSON

Can you elaborate?

@bluss
Copy link
Member Author

bluss commented Mar 14, 2017

Not yet, haven't gotten that far in the design.

@khurshid-alam
Copy link

Alright.

So it will index anything. Let's say I want to recursively index all png file from ~/Pictures/Screenshot at toplevel. We can do that by presenting all files (or file names) as json obj?

@bluss
Copy link
Member Author

bluss commented Mar 14, 2017

Yes, which leaves are created depends entirely on the output of the script. If it outputs one JSON record (if that's the format) per png file, those files are all part of the user source.

@bluss
Copy link
Member Author

bluss commented Mar 14, 2017

Json is easy to output from Python, and using external python scripts is not useless, but maybe there are other formats that are better. Big value in using an existing format with existing parser and typed values though.

@khurshid-alam
Copy link

khurshid-alam commented Mar 14, 2017

What about action? We still want to do something with it. For example opening those pngs with default image viewer?

@bluss
Copy link
Member Author

bluss commented Mar 14, 2017

I imagine they would show up as files, so they are just like any other .png file in kupfer (so the same actions).

It would be open for a plugin to implement a different leaf for them, but I don't think files should be represented in any other way than FileLeaf in kupfer.

@bluss
Copy link
Member Author

bluss commented Mar 14, 2017

So to clarify, the design IMO would be that user sources is a way to insert collections of objects (Leaves in Kupfer's terms) with the help of text based programs, using any of the builtin or plugin defined Leaves that support creation from (for example) JSON. It's not intended that user sources defines new classes of leaves.

@hugosenari
Copy link

Nice idea!

Now we need:

  • Define how user will set this sources
    • One or more sources
    • Static file or exec output
    • At preference interface or put exec files at specific directory (like plugins)
  • Define expected output from this sources
    • JSON or CSV
    • What information is required
  • Define Leaf interface
    • static method or kword at init

@hugosenari
Copy link

I like JSON but unix commands can easily output a 'CSV' (or CSV like output).

@bluss
Copy link
Member Author

bluss commented Mar 15, 2017

If the csv has named columns it should work well, then it's easy to map each row to a dictionary just like JSON; however then we don't have types. Majority will use strings anyway, but I don't want to distribute the lowest level of input parsing to the plugins, it should be central.

@hugosenari
Copy link

I liked this repo is some kind of early stage of what you proposed here.
And thinking about maybe we can adopt intents here ie:

  • tel:987654321 (is a telefone leaf);
  • http://asdfgh (is url leaf);
  • mailto://[email protected] (is a mail leaf);
  • file:///opt/kupfer/kupfer.png (is file leaf)

But, again would be hard create them from command lines. 🤔

@hugosenari
Copy link

A long time ago I found @spiritedflow kupfer-connectables plugin. For some reason a forgot them. LOL

It works with YAMLs 💩:
One for Leafs

locale: en_EN.UTF-8
cacti_id: 1
icon_name: network-server
actions:
  - ssh
  - cacti
  - ping

And other for Actions:

type: uri
name: Cacti charts
descr: View cacti charts for this host
icon_name: web-browser
uri: https://your-cacti-site/cacti/graph_view.php?action=tree&tree_id=6&leaf_id=%(cacti_id)d

Once again, is a bit hard create this files from command lines output.
But for user configuration is easy.

@hugosenari
Copy link

And the Great Bedkowski created user_sources.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants