Still Re-writing the Plugins
semicode-ltd opened this issue · 20 comments
We are re-writing the plugins with the plugins system so we didn't finish yet :)
and any help will be appreciated :)
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
I prefer the plugins in python if its all the same Im really good with it.
You can install the dependencies and run sarah as following :
make all
make install
cd bin
./sarah pluginname
Yes You can Write any Plugin You want in Python
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
You need to install libpeas-dev package :)
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
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
Sorry Friend this was a problem in the make file clone the repo again and try now
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
yes you are using an old repo! we made several fixes clone the repo now and try again :)
do as following :
cd sarah/
make
make install
cd bin
export LD_LIBRARY_PATH=.
export GI_TYPELIB_PATH=.
./sarah hi am kylespons
doh got it running!!!!!!!
I added some instructions to the readme and created a pull request thanks!!!!
Hey.
Can anyone guide me on how to write a plugin for sarah?
Thanks!
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.
hi @brunohanai it's worked
try
sudo pip3 install omdb
Thanks!
And can you explain the *.plugin
file?
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
btw there is already plugin for movies called watch check it in the plugins folder in this repo :)