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

Still Re-writing the Plugins #9

Open
semicode-ltd opened this issue Dec 16, 2016 · 20 comments
Open

Still Re-writing the Plugins #9

semicode-ltd opened this issue Dec 16, 2016 · 20 comments

Comments

@semicode-ltd
Copy link
Owner

We are re-writing the plugins with the plugins system so we didn't finish yet :)

@semicode-ltd
Copy link
Owner Author

and any help will be appreciated :)

@KyleSponz
Copy link
Contributor

KyleSponz commented Dec 16, 2016

Sure, I am having an issue getting sarah to run on my ubuntu system. I am getting the following errors

when I run valac main.vala
main.vala:27.3-27.5: error: The type name App' could not be found
App app = new App ();
^^^
`

============================================================================

and when I run sarah.vala
sarah.vala:53.10-53.13: error: The symbol Peas' could not be found
public Peas.Engine engine;
^^^^
sarah.vala:54.10-54.13: error: The symbol Peas' could not be found public Peas.ExtensionSet extension_set; ^^^^ sarah.vala:55.10-55.13: error: The symbol Peas' could not be found
public Peas.PluginInfo plugin;
^^^^
sarah.vala:66.22-66.25: error: The symbol Peas' could not be found unowned GLib.List<Peas.PluginInfo> plugin_list = this.engine.get_plugin_list (); ^^^^ sarah.vala:69.13-69.16: error: The symbol Peas' could not be found
foreach (Peas.PluginInfo plugin in plugin_list)
^^^^
`

I eagerly await your response

@KyleSponz
Copy link
Contributor

I prefer the plugins in python if its all the same Im really good with it.

@semicode-ltd
Copy link
Owner Author

You can install the dependencies and run sarah as following :
make all
make install
cd bin
./sarah pluginname

@semicode-ltd
Copy link
Owner Author

Yes You can Write any Plugin You want in Python

@KyleSponz
Copy link
Contributor

Got the following when I tried to run the make file :
sudo make all valac -o libsarah.so --library=sarah -H ./bin/sarah.h --gir=Sarah-1.0.gir -X -shared -X -fPIC --pkg libpeas-1.0 --pkg gmodule-2.0 sarah.vala -d ./bin /home/kyle/PycharmProjects/sarah/bin/sarah.vala.c:31:26: fatal error: libpeas/peas.h: No such file or directory compilation terminated. error: cc exited with status 256 Compilation failed: 1 error(s), 0 warning(s) Makefile:11: recipe for target 'sarahLib' failed make: *** [sarahLib] Error 1

@msupercoder
Copy link

You need to install libpeas-dev package :)

@KyleSponz
Copy link
Contributor

well it seems that helped some, it seems that the error is as follows and centered around the vala-extension.vala file found in the /plugins directory:

sudo make all valac -o libsarah.so --library=sarah -H ./bin/sarah.h --gir=Sarah-1.0.gir -X -shared -X -fPIC --pkg libpeas-1.0 --pkg gmodule-2.0 sarah.vala -d ./bin /home/kyle/PycharmProjects/sarah/bin/sarah.vala.c: In function ‘sarah_core_list’: /home/kyle/PycharmProjects/sarah/bin/sarah.vala.c:273:9: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] _tmp1_ = peas_engine_get_plugin_list (_tmp0_); ^ /home/kyle/PycharmProjects/sarah/bin/sarah.vala.c:314:24: warning: '#' flag used with ‘%s’ gnu_printf format [-Wformat=] fprintf (_tmp10_, "%#s \t %#s\n", _tmp12_, _tmp14_); ^ /home/kyle/PycharmProjects/sarah/bin/sarah.vala.c:314:24: warning: '#' flag used with ‘%s’ gnu_printf format [-Wformat=] /home/kyle/PycharmProjects/sarah/bin/sarah.vala.c: In function ‘sarah_app_init’: /home/kyle/PycharmProjects/sarah/bin/sarah.vala.c:525:63: warning: passing argument 3 of ‘_vala_string_array_contains’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] if (_vala_string_array_contains (_tmp13_, _tmp13__length1, _tmp12_)) { ^ /home/kyle/PycharmProjects/sarah/bin/sarah.vala.c:464:17: note: expected ‘gchar * {aka char *}’ but argument is of type ‘const gchar * {aka const char *}’ static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle) { ^ g-ir-compiler --shared-library=libsarah.so ./bin/Sarah-1.0.gir -o ./bin/Sarah-1.0.typelib valac -o sarah main.vala --vapidir ./bin --pkg libpeas-1.0 --pkg sarah -X -I./bin -X -L./bin -X -lsarah -d ./bin valac -o libhello.so --library=hello ./plugins/vala-extension.vala -X -shared -X -fPIC --vapidir ./bin --pkg sarah --pkg libpeas-1.0 -X -I./bin -X -L./bin -X -lsarah -d ./bin/plugins error: ./plugins/vala-extension.vala not found Compilation failed: 1 error(s), 0 warning(s) Makefile:17: recipe for target 'sarahPlugins' failed make: *** [sarahPlugins] Error 1

Thanks for being so awesome with my new guy questions, Ive never even heard of vala till I started playing around with sarah. Im having a blast regardless

@semicode-ltd
Copy link
Owner Author

its Okay Friend !
you need to install vala compiler itself so check this link i think its useful for you :
http://askubuntu.com/questions/612342/how-to-install-the-vala-environemt

@semicode-ltd
Copy link
Owner Author

Sorry Friend this was a problem in the make file clone the repo again and try now

@KyleSponz
Copy link
Contributor

KyleSponz commented Dec 20, 2016

Ran this got the valac package:
https://wiki.gnome.org/Projects/Vala/ValaOnLinux

got the following error:

valac -o libsarah.so --library=sarah -H ./bin/sarah.h --gir=Sarah-1.0.gir -X -shared -X -fPIC --pkg libpeas-1.0 --pkg gmodule-2.0 sarah.vala -d ./bin
/home/kyle/PycharmProjects/sarah/bin/sarah.vala.c: In function ‘sarah_core_list’:
/home/kyle/PycharmProjects/sarah/bin/sarah.vala.c:273:9: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
tmp1 = peas_engine_get_plugin_list (tmp0);
^
/home/kyle/PycharmProjects/sarah/bin/sarah.vala.c:314:24: warning: '#' flag used with ‘%s’ gnu_printf format [-Wformat=]
fprintf (tmp10, "%#s \t %#s\n", tmp12, tmp14);
^
/home/kyle/PycharmProjects/sarah/bin/sarah.vala.c:314:24: warning: '#' flag used with ‘%s’ gnu_printf format [-Wformat=]
/home/kyle/PycharmProjects/sarah/bin/sarah.vala.c: In function ‘sarah_app_init’:
/home/kyle/PycharmProjects/sarah/bin/sarah.vala.c:525:63: warning: passing argument 3 of ‘_vala_string_array_contains’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
if (_vala_string_array_contains (tmp13, _tmp13__length1, tmp12)) {
^
/home/kyle/PycharmProjects/sarah/bin/sarah.vala.c:464:17: note: expected ‘gchar * {aka char }’ but argument is of type ‘const gchar * {aka const char }’
static gboolean _vala_string_array_contains (gchar
stack, int stack_length, gchar* needle) {
^
g-ir-compiler --shared-library=libsarah.so ./bin/Sarah-1.0.gir -o ./bin/Sarah-1.0.typelib
valac -o sarah main.vala --vapidir ./bin --pkg libpeas-1.0 --pkg sarah -X -I./bin -X -L./bin -X -lsarah -d ./bin
valac -o libhello.so --library=hello ./plugins/vala-extension.vala -X -shared -X -fPIC --vapidir ./bin --pkg sarah --pkg libpeas-1.0 -X -I./bin -X -L./bin -X -lsarah -d ./bin/plugins
error: ./plugins/vala-extension.vala not found
Compilation failed: 1 error(s), 0 warning(s)
Makefile:17: recipe for target 'sarahPlugins' failed
make: *** [sarahPlugins] Error 1

@msupercoder
Copy link

yes you are using an old repo! we made several fixes clone the repo now and try again :)

@msupercoder
Copy link

do as following :
cd sarah/
make
make install
cd bin
export LD_LIBRARY_PATH=.
export GI_TYPELIB_PATH=.
./sarah hi am kylespons

@KyleSponz
Copy link
Contributor

doh got it running!!!!!!!

I added some instructions to the readme and created a pull request thanks!!!!

@aissat aissat closed this as completed Dec 20, 2016
@semicode-ltd semicode-ltd reopened this Dec 20, 2016
@nikssardana
Copy link

Hey.
Can anyone guide me on how to write a plugin for sarah?
Thanks!

@brunohanai
Copy link

Hi,

I'd like to know this too. Here is what I did:

Created a dir in plugins dir ("/plugins/imdb")

Created a file named imdb.plugin (I dont know what each key=value really means):

[Plugin]
Module=imdb
Loader=python3
Name=imdb
Description=get movie's info

Created a file named imdb.py:

import os
import sys

import gi
gi.require_version('Peas', '1.0')
gi.require_version('Sarah', '1.0')
from gi.repository import GObject, Peas, Sarah

import omdb

class ImdbPlugin(GObject.Object, Sarah.IExtension):
    __gtype_name__ = 'ImdbPlugin'

    object = GObject.property(type=GObject.Object)

    def do_activate(self, args, argv):
        print(args)

    def do_deactivate(self):
        pass

The command now appears on sarah list command.

But I got the error:

(process:765): libpeas-WARNING **: Error importing plugin 'imdb':
ImportError: No module named 'omdb'
** (process:765): CRITICAL **: sarah_iextension_activate: assertion 'self != NULL' failed

PS: I installed omdb with pip install omdb

Please help me with that guys.

@aissat
Copy link
Collaborator

aissat commented Dec 23, 2016

hi @brunohanai it's worked
try
sudo pip3 install omdb

@brunohanai
Copy link

Thanks!

And can you explain the *.plugin file?

@0vulns
Copy link

0vulns commented Dec 23, 2016

Imagine with me that you want to create a plugin to called "foo" to print Hi brunohanai , The *.plugin file would be something like this:
Before we go ahead we need to know some rules about plugin file:

  • The file name and Module name must be in lowercase [a-z]
  • So far Sarah support python3 & c loader only.
    The plugin file:
[Plugin]
Module=foo
Loader=python3
Name=foo
Description=foo and bar!

I think Name is the name of command

foo.py

import gi
gi.require_version('Peas', '1.0')
gi.require_version('Sarah', '1.0')
from gi.repository import GObject, Peas, Sarah


class FooPlugin(GObject.Object, Sarah.IExtension):
    __gtype_name__ = 'FooPlugin'

    object = GObject.property(type=GObject.Object)

    def do_activate(self, args, argv):
        print("Foo", args)

    def do_deactivate(self):
        pass

@semicode-ltd
Copy link
Owner Author

btw there is already plugin for movies called watch check it in the plugins folder in this repo :)

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

7 participants