technic / enigma2_example

enigma2 plugin project example with Docker and VS Code configuration
MIT License
15 stars 9 forks source link

Help for installation #2

Closed aldobel closed 3 years ago

aldobel commented 3 years ago

Hi, as the title suggests, I need a hand to install the whole package. I'm new and therefore I can't understand some steps, and I can't even get to the automatic completion of the editor. Please, it would be an indispensable tool for me to create new plugins for enigma2. Thank you

technic commented 3 years ago

Hi! Unfortunately I don't have more detailed guide written anywhere. Can you explain which steps did you make, and where have you stuck? For automatic completion, can you tell which language server are you using. It is written in the vscode settings.

aldobel commented 3 years ago

Hi, thanks for the answer. First I create the workspace with VSCode, by dragging a folder named "plugin_enigma2", then:

  1. I create a folder and name it src;
  2. I create a "plugin.py" file inside;
  3. I create the folder ".venv" in the root directory, thus having /plugin_enigma2/.venv;
  4. I open the console in VSCode and type “pipenv install”;
  5. I create the “.env” file in the main directory so as to have /plugin_enigma2/.env;
  6. Inside the "plugin_enigma2" folder I copy the folder from git (downloaded previously) enigma2_develop;
  7. I rename enigma2_develop to enigma2;
  8. In the .env file I write the path as per your example, because I think it works well in my case too;
  9. I restart VSCode, and try to write, but no autocomplete. Where am I wrong? Thanks again
technic commented 3 years ago

Oh, I see. If you have file plugin_enigma2/.env and plugin_enigma2/enigma2

Then in .env you put a relative path to enigma2 folder So PYTHONPATH=enigma2;enigma2/lib/python

aldobel commented 3 years ago

Ok thanks ... I'll try as soon as I can and I'll let you know, also because I will need a big hand with docker, which I have never used

aldobel commented 3 years ago

Nothing to do...I tried and tried, but nothing, always the same result, that is, no autocompletion. I've attached my project folder, see if you can figure out what it could be. Thank you plugin_enigma2.zip

technic commented 3 years ago

Does completion of system modules work, e.g. os, sys etc?

image

aldobel commented 3 years ago

Actually, I don't even complete the 'basic' modules like: os, sys etc ... so the problem is another. But what? helpppppppp

technic commented 3 years ago

Man, this kinda beyond the scope of the topic here. If you can't complete basic python modules then ask in vscode support, chat, whatever. Maybe you need to install python vscode extension or something is broken with your python installation.

aldobel commented 3 years ago

Ok, I check my basic settings better (even if they have always gone, perhaps by tweaking a there and a bit here, I have disabled / uninstalled some extensions). As soon as I've done my checks, I'll notify you.

aldobel commented 3 years ago

Hi, sorry if I'm only writing now, but I've had a little busy these days. I can confirm that now the automatic insertion works perfectly (I forgot to pass the vscode app in the applications folder). Now my problem is docker: having never used it, I don't know where to start; i did some tests and first i installed docker desktop (macOs), then i downloaded the repository from here: docker run --rm -p 5900: 5900 --name enigma2_box technic93 / e2xvfb x11vnc -forever after which I created the new dockerfile with these lines:

FROM technic93 / e2xvfb: latest
CMD ["x11vnc", "-forever"]

RUN pip install ptvsd
EXPOSE 5678
COPY mytest-ptvsd.py /opt/mytest-ptvsd.py 

I create the docker-compose.yml file, and compile it like this:

version: '2'
services:
  enigma2:
    container_name: enigma2
    build:
      context:.
    ports:
      - 4444: 4444
    volumes:
      - './src:/usr/lib/enigma2/python/Plugins/Extensions/Example'

I go to docker-compose.yml and right click and go to compose up; it creates the image for me and starts it, but from the browser it doesn't show me anything. What am I doing wrong?

technic commented 3 years ago

Hi. You don't need to do docker run manually, because docker-compose does it for you. There will be nothing in the internet browser, except enigma2 web interface. You need to setup port mapping in the same way as in the readme. There are two ports to expose: one for VNC, another for debugger. With this you should be able do connect to image and see black screen. You can start enigma2 then, with docker exec ...

aldobel commented 3 years ago

Thanks for the speed ... I added another port, and it doesn't give me more errors, this is the result:


Executing task: docker-compose -f "docker-compose.yml" up -d --build <

Building enigma2
Step 1/5: FROM technic93 / e2xvfb: latest
 ---> 53cfbb24ca4d
Step 2/5: CMD ["x11vnc", "-forever"]
 ---> Using cache
 ---> d242474c8289
Step 3/5: RUN pip install ptvsd
 ---> Using cache
 ---> 0117ada7a84f
Step 4/5: EXPOSE 5678
 ---> Using cache
 ---> 447d3e9fcd73
Step 5/5: COPY mytest-ptvsd.py /opt/mytest-ptvsd.py
 ---> Using cache
 ---> 275b14fe6ee9

Successfully built 275b14fe6ee9
Successfully tagged plugin_enigma2_enigma2: latest
enigma2 is up-to-date

I exit the terminal and give the command: docker exec -it enigma2 / usr / bin / enigma2 and this is the result:

PYTHONPATH: / usr / lib / enigma2 / python
DVB_API_VERSION 5 DVB_API_VERSION_MINOR 10
ENIGMA_DEBUG_LVL = 3
[MAIN] executing main
no profile data available
Traceback (most recent call last):
  File "/usr/lib/enigma2/python/Components/PluginComponent.py", line 52, in readPluginList
    plugin = my_import ('.'. join (["Plugins", c, pluginname, "plugin"]))
  File "/usr/lib/enigma2/python/Tools/Import.py", line 2, in my_import
    mod = __import __ (name)
ImportError: No module named Example.plugin

Browser keeps giving me error at localhost: 4444, localhost: 2222

technic commented 3 years ago

What kind of browser are you taking about? What do you expect see at port 4444? 😲

Regarding the python error, I think you forgot to put __init__.py file.

aldobel commented 3 years ago

I sincerely expect to see a virtual enigma2 box, I expect it on port 4444 because it is the one I have set. Now I don't know if I keep making something wrong and what ... anyway now I compile the files in the src folder after I have inserted the __init__.py file inside it

technic commented 3 years ago

No, it doesn't work like this. The thing you put in docker compose is just a port forwarding from the container to the host OS. In order to see anything you need to have a program in the container which actually listen the specified port. In case of x11vnc the default port is 5900. So you will find absolutely nothing on 4444.

aldobel commented 3 years ago

But does x11vnc have to be installed? If so, as an installation (on Mac) or as a VSCode extension?

technic commented 3 years ago

The x11vnc is installed in container already. You need to install VNC client on Mac. (This is kind of TeamViewer). I use this on windows.

aldobel commented 3 years ago

Hi, now I'm trying and I downloaded realvnc, I log in and type the address localhost: 5900 and it asks me for a user and a pass, what do I do? Schermata 2021-02-11 alle 22 35 17

technic commented 3 years ago

There shouldn't be any user pass

aldobel commented 3 years ago

I understand ... we use the same vnc, as you do?

technic commented 3 years ago

we use the same vnc, as you do?

yes

technic commented 3 years ago

When you do docker-compose up you should see

YOU ARE RUNNING X11VNC WITHOUT A PASSWORD!!

So it shouldn't ask for password

aldobel commented 3 years ago

After issuing the command: docker-compose up gives me this result.

enigma2 is up-to-date
Attaching to enigma2
enigma2    |  * Starting Apache httpd web server apache2
enigma2    | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.31.0.2. Set the 'ServerName' directive globally to suppress this message
enigma2    |  * 
enigma2    | start Xvfb
enigma2    | exec command x11vnc -forever
enigma2    | ###############################################################
enigma2    | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
enigma2    | #@                                                           @#
enigma2    | #@  **  WARNING  **  WARNING  **  WARNING  **  WARNING  **   @#
enigma2    | #@                                                           @#
enigma2    | #@        YOU ARE RUNNING X11VNC WITHOUT A PASSWORD!!        @#
enigma2    | #@                                                           @#
enigma2    | #@  This means anyone with network access to this computer   @#
enigma2    | #@  may be able to view and control your desktop.            @#
enigma2    | #@                                                           @#
enigma2    | #@ >>> If you did not mean to do this Press CTRL-C now!! <<< @#
enigma2    | #@                                                           @#
enigma2    | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
enigma2    | #@                                                           @#
enigma2    | #@  You can create an x11vnc password file by running:       @#
enigma2    | #@                                                           @#
enigma2    | #@       x11vnc -storepasswd password /path/to/passfile      @#
enigma2    | #@  or   x11vnc -storepasswd /path/to/passfile               @#
enigma2    | #@  or   x11vnc -storepasswd                                 @#
enigma2    | #@                                                           @#
enigma2    | #@  (the last one will use ~/.vnc/passwd)                    @#
enigma2    | #@                                                           @#
enigma2    | #@  and then starting x11vnc via:                            @#
enigma2    | #@                                                           @#
enigma2    | #@      x11vnc -rfbauth /path/to/passfile                    @#
enigma2    | #@                                                           @#
enigma2    | #@  an existing ~/.vnc/passwd file from another VNC          @#
enigma2    | #@  application will work fine too.                          @#
enigma2    | #@                                                           @#
enigma2    | #@  You can also use the -passwdfile or -passwd options.     @#
enigma2    | #@  (note -passwd is unsafe if local users are not trusted)  @#
enigma2    | #@                                                           @#
enigma2    | #@  Make sure any -rfbauth and -passwdfile password files    @#
enigma2    | #@  cannot be read by untrusted users.                       @#
enigma2    | #@                                                           @#
enigma2    | #@  Use x11vnc -usepw to automatically use your              @#
enigma2    | #@  ~/.vnc/passwd or ~/.vnc/passwdfile password files.       @#
enigma2    | #@  (and prompt you to create ~/.vnc/passwd if neither       @#
enigma2    | #@  file exists.)  Under -usepw, x11vnc will exit if it      @#
enigma2    | #@  cannot find a password to use.                           @#
enigma2    | #@                                                           @#
enigma2    | #@                                                           @#
enigma2    | #@  Even with a password, the subsequent VNC traffic is      @#
enigma2    | #@  sent in the clear.  Consider tunnelling via ssh(1):      @#
enigma2    | #@                                                           @#
enigma2    | #@    http://www.karlrunge.com/x11vnc/#tunnelling            @#
enigma2    | #@                                                           @#
enigma2    | #@  Or using the x11vnc SSL options: -ssl and -stunnel       @#
enigma2    | #@                                                           @#
enigma2    | #@  Please Read the documention for more info about          @#
enigma2    | #@  passwords, security, and encryption.                     @#
enigma2    | #@                                                           @#
enigma2    | #@    http://www.karlrunge.com/x11vnc/faq.html#faq-passwd    @#
enigma2    | #@                                                           @#
enigma2    | #@  To disable this warning use the -nopw option, or put     @#
enigma2    | #@  'nopw' on a line in your ~/.x11vncrc file.               @#
enigma2    | #@                                                           @#
enigma2    | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
enigma2    | ###############################################################
enigma2    | 11/02/2021 22:06:45 x11vnc version: 0.9.13 lastmod: 2011-08-10  pid: 1
enigma2    | 11/02/2021 22:06:45 Using X display :99
enigma2    | 11/02/2021 22:06:45 rootwin: 0x1e4 reswin: 0x200001 dpy: 0xf27b2a0
enigma2    | 11/02/2021 22:06:45 
enigma2    | 11/02/2021 22:06:45 ------------------ USEFUL INFORMATION ------------------
enigma2    | 11/02/2021 22:06:45 X DAMAGE available on display, using it for polling hints.
enigma2    | 11/02/2021 22:06:45   To disable this behavior use: '-noxdamage'
enigma2    | 11/02/2021 22:06:45 
enigma2    | 11/02/2021 22:06:45   Most compositing window managers like 'compiz' or 'beryl'
enigma2    | 11/02/2021 22:06:45   cause X DAMAGE to fail, and so you may not see any screen
enigma2    | 11/02/2021 22:06:45   updates via VNC.  Either disable 'compiz' (recommended) or
enigma2    | 11/02/2021 22:06:45   supply the x11vnc '-noxdamage' command line option.
enigma2    | 11/02/2021 22:06:45 
enigma2    | 11/02/2021 22:06:45 Wireframing: -wireframe mode is in effect for window moves.
enigma2    | 11/02/2021 22:06:45   If this yields undesired behavior (poor response, painting
enigma2    | 11/02/2021 22:06:45   errors, etc) it may be disabled:
enigma2    | 11/02/2021 22:06:45    - use '-nowf' to disable wireframing completely.
enigma2    | 11/02/2021 22:06:45    - use '-nowcr' to disable the Copy Rectangle after the
enigma2    | 11/02/2021 22:06:45      moved window is released in the new position.
enigma2    | 11/02/2021 22:06:45   Also see the -help entry for tuning parameters.
enigma2    | 11/02/2021 22:06:45   You can press 3 Alt_L's (Left "Alt" key) in a row to 
enigma2    | 11/02/2021 22:06:45   repaint the screen, also see the -fixscreen option for
enigma2    | 11/02/2021 22:06:45   periodic repaints.
enigma2    | 11/02/2021 22:06:45 
enigma2    | 11/02/2021 22:06:45 XFIXES available on display, resetting cursor mode
enigma2    | 11/02/2021 22:06:45   to: '-cursor most'.
enigma2    | 11/02/2021 22:06:45   to disable this behavior use: '-cursor arrow'
enigma2    | 11/02/2021 22:06:45   or '-noxfixes'.
enigma2    | 11/02/2021 22:06:45 using XFIXES for cursor drawing.
enigma2    | 11/02/2021 22:06:45 GrabServer control via XTEST.
enigma2    | 11/02/2021 22:06:45 
enigma2    | 11/02/2021 22:06:45 Scroll Detection: -scrollcopyrect mode is in effect to
enigma2    | 11/02/2021 22:06:45   use RECORD extension to try to detect scrolling windows
enigma2    | 11/02/2021 22:06:45   (induced by either user keystroke or mouse input).
enigma2    | 11/02/2021 22:06:45   If this yields undesired behavior (poor response, painting
enigma2    | 11/02/2021 22:06:45   errors, etc) it may be disabled via: '-noscr'
enigma2    | 11/02/2021 22:06:45   Also see the -help entry for tuning parameters.
enigma2    | 11/02/2021 22:06:45   You can press 3 Alt_L's (Left "Alt" key) in a row to 
enigma2    | 11/02/2021 22:06:45   repaint the screen, also see the -fixscreen option for
enigma2    | 11/02/2021 22:06:45   periodic repaints.
enigma2    | 11/02/2021 22:06:45 
enigma2    | 11/02/2021 22:06:45 XKEYBOARD: number of keysyms per keycode 7 is greater
enigma2    | 11/02/2021 22:06:45   than 4 and 51 keysyms are mapped above 4.
enigma2    | 11/02/2021 22:06:45   Automatically switching to -xkb mode.
enigma2    | 11/02/2021 22:06:45   If this makes the key mapping worse you can
enigma2    | 11/02/2021 22:06:45   disable it with the "-noxkb" option.
enigma2    | 11/02/2021 22:06:45   Also, remember "-remap DEAD" for accenting characters.
enigma2    | 11/02/2021 22:06:45 
enigma2    | 11/02/2021 22:06:45 X FBPM extension not supported.
enigma2    | 11/02/2021 22:06:45 X display is not capable of DPMS.
enigma2    | 11/02/2021 22:06:45 --------------------------------------------------------
enigma2    | 11/02/2021 22:06:45 
enigma2    | 11/02/2021 22:06:45 Default visual ID: 0x21
enigma2    | 11/02/2021 22:06:45 Read initial data from X display into framebuffer.
enigma2    | 11/02/2021 22:06:45 initialize_screen: fb_depth/fb_bpp/fb_Bpl 16/16/2560
enigma2    | 11/02/2021 22:06:45 
enigma2    | 11/02/2021 22:06:45 X display :99 is 16bpp depth=16 true color
enigma2    | 11/02/2021 22:06:45 
enigma2    | 11/02/2021 22:06:45 Autoprobing TCP port 
enigma2    | 11/02/2021 22:06:45 Autoprobing selected TCP port 5900
enigma2    | 11/02/2021 22:06:45 Autoprobing TCP6 port 
enigma2    | 11/02/2021 22:06:45 Autoprobing selected TCP6 port 5900
enigma2    | 11/02/2021 22:06:45 listen6: bind: Address already in use
enigma2    | 11/02/2021 22:06:45 Not listening on IPv6 interface.
enigma2    | 11/02/2021 22:06:45 
enigma2    | 11/02/2021 22:06:45 Xinerama is present and active (e.g. multi-head).
enigma2    | 11/02/2021 22:06:45 Xinerama: number of sub-screens: 1
enigma2    | 11/02/2021 22:06:45 Xinerama: no blackouts needed (only one sub-screen)
enigma2    | 11/02/2021 22:06:45 
enigma2    | 11/02/2021 22:06:45 fb read rate: 844 MB/sec
enigma2    | 11/02/2021 22:06:45 fast read: reset -wait  ms to: 10
enigma2    | 11/02/2021 22:06:45 fast read: reset -defer ms to: 10
enigma2    | 11/02/2021 22:06:45 The X server says there are 10 mouse buttons.
enigma2    | 11/02/2021 22:06:45 screen setup finished.
enigma2    | 11/02/2021 22:06:45 
enigma2    | 11/02/2021 22:06:45 WARNING: You are running x11vnc WITHOUT a password.  See
enigma2    | 11/02/2021 22:06:45 WARNING: the warning message printed above for more info.
enigma2    | 11/02/2021 22:06:45 
enigma2    | 
enigma2    | The VNC desktop is:      48eeea529d56:0
enigma2    | PORT=5900
enigma2    | 
enigma2    | ******************************************************************************
enigma2    | Have you tried the x11vnc '-ncache' VNC client-side pixel caching feature yet?
enigma2    | 
enigma2    | The scheme stores pixel data offscreen on the VNC viewer side for faster
enigma2    | retrieval.  It should work with any VNC viewer.  Try it by running:
enigma2    | 
enigma2    |     x11vnc -ncache 10 ...
enigma2    | 
enigma2    | One can also add -ncache_cr for smooth 'copyrect' window motion.
enigma2    | More info: http://www.karlrunge.com/x11vnc/faq.html#faq-client-caching
enigma2    | 

Now what do I do to see the view?

technic commented 3 years ago

It's correct. You see this line telling you that there aren't passwords. Try to leave password blank I dunno. I don't see any particular issue here.

aldobel commented 3 years ago

At address localhost: 5900, it asks me for user and pass and leaving it blank, gives me an error: An authentication error occurred. See the VNC Server error log for details.

technic commented 3 years ago

So, what is in the server log?!

technic commented 3 years ago

I think you have another VNC server running on this port. Maybe you have also installed real VNC server? Or anything else on Mac.

aldobel commented 3 years ago

I also installed realvnc's VNCServer. Now I try to uninstall the server

technic commented 3 years ago

Dude, why don't you follow the readme.

aldobel commented 3 years ago

Because? I have followed everything more or less to the letter, but then I am very inexperienced and I can make mistakes very easily ... I thank you infinitely for the great hand you are giving me, but unfortunately I cannot finish this configuration.

technic commented 3 years ago

Did you remove the real VNC server? You should have only one VNC Server, which is x11vnc that we launch in docker.

aldobel commented 3 years ago

Hi, yes I have removed the VNC server and I only have the VNC view; however I don't understand why, it always asks me for a username and password ... tonight I'll try again, maybe uninstalling and reinstalling everything again! Thanks so much!

technic commented 3 years ago

You should see connection attempts in the container log, in the output from docker up. Otherwise there is something weird and you are connecting elsewhere. You can stop the docker and try to connect. You must no longer see password prompt. Those are obvious checks to do...

aldobel commented 3 years ago

Hi, it's been a long time now, but in these days I have tried and tried several times with docker to start a virtual machine to display an e2 box but never happened. Then I came across the other method you wrote, that is with vagrant and virtualbox, encountering 2 problems:

Sorry if it's always me who creates these problems, but if you can help me I will thank you very much. Schermata 2021-02-22 alle 19 53 41

technic commented 3 years ago

I don't use the old method now. So you are on your own with it, sorry. Please don't ask about it in this issue because it is a different topic.

technic commented 3 years ago

@aldobel I honestly don't understand what can go wrong with docker. Can you show me the output of docker ps after you start container with docker compose?

aldobel commented 3 years ago

This is what I get out of giving docker ps in a shell, while docker-compose up is running

Schermata 2021-02-22 alle 20 17 18

aldobel commented 3 years ago

I connected to the address 0.0.0.0:55000 and, for the first time, vnc gives me a black screen (the other times, it showed me the screen of my mac), but it stays black and does nothing, even pressing space . Schermata 2021-02-22 alle 20 28 16

technic commented 3 years ago

This is correct behavior. As I told you

With this you should be able do connect to image and see black screen. You can start enigma2 then, with docker exec ...

Now you should start enigma

Now it is possible to connect to localhost:~5900~ with a VNC client and see a XServer's black screen. You can bring up enigma2 there by docker exec -it enigma2 /usr/bin/enigma2. You should be able to navigate enigma2 menu ("space" button) and find your plugin.

aldobel commented 3 years ago

Thank you very much ... you are great !!!!! Solved everything, I don't know how, but by giving docker exec -it enigma2 / usr / bin / enigma2 I managed to see screen e2 at 0.0.0.0:55000. A very last thing (superfluous) can I change the IP connection to the vnc? Thanks and thanks again

technic commented 3 years ago

I think the ip can be localhost or 127.0.0.1.

I don't know how, but by giving `docker exec -it enigma2 /usr/bin/enigma2

Because the docker images start with the blank XServer. Usually one have some kind of Desktop environment there, but we don't need it, since the only thing we want to launch is enigma2. Therefore the screen is always black. Then with docker exec you launch enigma2 instance. After changes to the code you should stop (kill) it and launch again. So this will be your development cycle.

aldobel commented 3 years ago

One last thing, I don't know why, but to activate the automatic filling of forms, I have to enter all the relative directory example:

Inside the .env file is: PYTHONPATH=../enigma2/lib/python;../enigma2. Where am I wrong? how do you configure / write the .env file? Thank you

technic commented 3 years ago

Do you know what .. means in the path?

I commented on this already long time ago https://github.com/technic/enigma2_example/issues/2#issuecomment-773924394

aldobel commented 3 years ago

Hey friend, all solved...in the .env file it only had to say:

Thanks for all the support

aldobel commented 3 years ago

Hi, I wanted to ask you, how can I add a usb to vnc (if you can) or how to pass files inside the virtual e2 box. I tried adding at launch.json file:

"pathMappings": [
                 {
                     "localRoot":"${workspaceRoot}\\src",
                     "remoteRoot":"/usr/lib/enigma2/python/Plugins/Extensions/Example",
                 },
                 {
                     "localRoot":"userbouquet.LastScanned.tv",
                     "remoteRoot":"/etc/enigma2/"
                 }
    ] 

but to no avail. Thanks again

technic commented 3 years ago

how to pass files inside the virtual e2 box.

Use the volumes option in docker-compose.yml