extrafresh Posted August 30, 2023 Posted August 30, 2023 I have followed the tutorial here https://hak5.github.io/mk7-docs/docs/modules/modules/ to create a new module. Firstly the documentation appears to be incorrect and I had to make changes to get the first 2 examples working. The last example where a python script is used for the backend doesn't seem to work. It packages and uploads to the pineapple fine but the service for the module never seems to run. If I SSH onto the pineapple and run module.py manually everything works, but that doesn't happen automatically when I use the module. Am I missing something obvious, or is there a step missing from the tutorial that covers this?
dark_pyrro Posted August 31, 2023 Posted August 31, 2023 I guess you have to be more detailed about what's not working to get some relevant response. Modules have been released over time based on that documentation and I haven't seen any real complaints, so it's difficult to guess what might be wrong. Describe your work flow step by step and where the documentation/examples are failing by telling exactly what you're doing and reference the docs. Your own module code is also good to see to be able to spot some eventual flaws in the implementation.
extrafresh Posted August 31, 2023 Author Posted August 31, 2023 Sorry, should have included that in the original post. When I launch my module I get the busy spinner and I can see that the request is waiting for a response. Then after some time I get an error 500 with the message 'error: "start tries have been exceeded"'. Whilst ssh'd onto the pineapple I can see that the module.py service is never running, whereas if I use a working module I can see that process running when I launch the module. Here's the code I'm using. someThing.component.html <mat-card> <mat-card-title>Welcome to someThing</mat-card-title> <mat-card-content> <button mat-flat-button color="accent" (click)="doAThing();"> Send the request </button> <br> <span>Response: {{apiResponse}}</span> </mat-card-content> </mat-card> someThing.component.ts import { Component, OnInit } from '@angular/core'; import { ApiService } from '../services/api.service'; @Component({ selector: 'lib-someThing', templateUrl: './someThing.component.html', styleUrls: ['./someThing.component.css'] }) export class someThingComponent implements OnInit { constructor(private API: ApiService) { } apiResponse = 'Do something'; doAThing(): void { this.API.request({ module: 'someThing', action: 'hello', }, (response) => { this.apiResponse = response; }) } ngOnInit() { } } module.py #!/usr/bin/env python3 import logging from pineapple.modules import Module, Request module = Module('someThing', logging.DEBUG) @module.handles_action('hello') def stuff(request): return 'Blah' if __name__ == '__main__': module.start() In terms of documentation that didn't work - one example is that the tutorial doesn't include that you have to use {{ apiResponse }} in the html in order to render the response onto the page.
extrafresh Posted August 31, 2023 Author Posted August 31, 2023 I'd like to add that I've fixed the problem with a bit of luck. The error was due to Windows line returns within my PyCharm project. There was no useful output on the pineapple or returned from the API to point me in that direction though, so if there is a good way to debug the loading of modules I would be very interested to know.
dark_pyrro Posted September 1, 2023 Posted September 1, 2023 I guess that Windows isn't the "first choice" when it comes to Pineapple development, that's why it hasn't really been an issue generally. Using sed on the files when they have been transferred to the Pineapple could be a way of getting rid of Windows ^M occurrences in the files.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.