MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. sureshkocherla
    3. Topics
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    S
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 4
    • Groups 0

    Topics

    • S

      Custom module to run python script

      Watching Ignoring Scheduled Pinned Locked Moved Development
      4
      1 Votes
      4 Posts
      4k Views
      strawberry 3.141S
      @Sputnik the facerecognition moduel of @paviro makes also heavy use of python scripts, take a look here https://github.com/paviro/MMM-Facial-Recognition/blob/master/node_helper.js
    • S

      python script into MagicMirror module

      Watching Ignoring Scheduled Pinned Locked Moved Hardware
      4
      0 Votes
      4 Posts
      4k Views
      ?
      @sureshkocherla Ok, Let’s see the example. MMM-Tools is using several external shell scripts in the module. https://github.com/eouia/MMM-Tools See the node_helpers.js (https://github.com/eouia/MMM-Tools/blob/master/node_helper.js) First, Child process could not be used on the frontend, so you need to build node_helpers.js for it. in line 10 var exec = require('child_process').exec child_proces.exec is declared to use. You might need other methods like spawn or fork for your purpose. in line 123. getIP : function() { exec (this.scripts['IP'], (err, stdout, stderr)=>{ if (err == null) { var matched = stdout.trim().match(/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/) this.status['IP'] = (matched) ? matched[0] : "Unknown" } }) }, this is all for your using exec. exec ("your command", function callback(error, outputonsuccess, outputonerr) { console.log(error, outputonsuccess, outputonerror) }) Try this in your module. ※ child_process.exec is a just simple method to get result of external command. But when you need more complexed function, you could consider spawn or fork or execFile instead exec https://dzone.com/articles/understanding-execfile-spawn-exec-and-fork-in-node this doc will be help.
    • S

      MMM-Swipe installation & work flow

      Watching Ignoring Scheduled Pinned Locked Moved Hardware
      1
      0 Votes
      1 Posts
      855 Views
      S
      MMM-Swipe installation & work flow
    • 1 / 1