semicode-ltd / sarah

Terminal Assistant For SemiCode OS
http://www.semicodeos.com/sarah
GNU General Public License v2.0
196 stars 67 forks source link

Still Re-writing the Plugins #9

Open semicode-ltd opened 7 years ago

semicode-ltd commented 7 years ago

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

semicode-ltd commented 7 years ago

and any help will be appreciated :)

KyleSponz commented 7 years ago

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 nameApp' could not be found App app = new App (); ^^^ `

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

and when I run sarah.vala sarah.vala:53.10-53.13: error: The symbolPeas' 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 symbolPeas' 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 symbolPeas' could not be found foreach (Peas.PluginInfo plugin in plugin_list) ^^^^ `

I eagerly await your response

KyleSponz commented 7 years ago

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

semicode-ltd commented 7 years ago

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

semicode-ltd commented 7 years ago

Yes You can Write any Plugin You want in Python

KyleSponz commented 7 years ago

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 commented 7 years ago

You need to install libpeas-dev package :)

KyleSponz commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

KyleSponz commented 7 years ago

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 commented 7 years ago

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

msupercoder commented 7 years ago

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

KyleSponz commented 7 years ago

doh got it running!!!!!!!

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

nikssardana commented 7 years ago

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

brunohanai commented 7 years ago

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 commented 7 years ago

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

brunohanai commented 7 years ago

Thanks!

And can you explain the *.plugin file?

0-ali commented 7 years ago

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:

[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 commented 7 years ago

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