我正在创建一个电子应用程序,我需要扫描和更新需要root权限的文件.我知道我可以用这种方式使用sudo.exec()运行这样的命令:
sudo.exec ("rm /private/var/log/fsck_hfs.log", options, (e, stdout, stderr) => {});
Run Code Online (Sandbox Code Playgroud)
甚至我可以在脚本中放置多个命令并使用单个sudo.exec()执行它们.在我的情况下,命令需要在不同的时间点执行,我不能用一个脚本执行它们.用户一次又一次地授予权限是令人讨厌的.
我尝试用另一种方式(运行一段代码,其中所有需要root权限的代码都可以执行).为此,我在这里发布了另一个问题.但似乎不可能.
现在我想要一种获得权限的方法,一旦使用安装应用程序(因为大多数应用程序在用户安装后都会这样做)并且能够在整个应用程序中使用sudo.exec()或其他一些方法来执行命令(最好也是代码) fs.readdir等)需要root权限.
我将Angular 2与Electron一起使用,并希望继续在后台运行进程以显示通知。我为此使用了永远的监视器,它只能在开发模式下工作,但是当我使用电子打包程序打包我的应用程序时,它将停止工作。我的代码如下所示:
主要
exports.runBackgroundProcess = () => {
// Run a background process forever
var forever = require('forever-monitor');
var child = new(forever.Monitor)('src/assets/notification-process.js',
{
env: {ELECTRON_RUN_AS_NODE: 1},
options: []
});
child.start();
}
Run Code Online (Sandbox Code Playgroud)
我在main.ts中编写了一个函数,当从角度组件中调用该函数时将运行后台进程。notification-process.js中的代码如下:
notification-process.js
notifier = require('node-notifier')
notifierFun = (msg) => {
notifier.notify({
title: 'Notify Me',
message: msg,
wait: true
});
}
var CronJob = require('cron').CronJob;
new CronJob('* * * * * *', function() {
notifierFun("Message from notification process");
});
Run Code Online (Sandbox Code Playgroud)
最后我从app.component.ts调用函数
let main_js = this.electronService.remote.require("./main.js");
main_js.runBackgroundProcess();
Run Code Online (Sandbox Code Playgroud) 我正在训练一个神经网络,根据帖子的数量,帖子的类别(视频,链接,状态等)和每个帖子的评论和评论数来预测Facebook页面粉丝增长的数量.因此,针对多个实例存在单个标签,因为每天计算标签(fan_growth)(不是针对每个帖子):

这里的日期,日期,链接,视频,状态,反应,评论和分享都是功能,而fan_growth是标签.如何针对多个实例使用单个标签?再次使用'100'时,所有前3个实例都不正确.
python machine-learning neural-network deep-learning tensorflow
我使用beginShape、endShape和curveVertex创建了一个形状。我的代码看起来像这样:
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
strokeWeight(5);
point(84, 91);
point(68, 19);
point(21, 17);
point(32, 91);
strokeWeight(1);
fill(0); // HOW TO FILL WITH IMAGE
beginShape();
curveVertex(84, 91);
curveVertex(84, 91);
curveVertex(68, 19);
curveVertex(21, 17);
curveVertex(32, 91);
curveVertex(32, 91);
endShape(CLOSE);
}
Run Code Online (Sandbox Code Playgroud)
我想用图像填充它,而不是用颜色填充形状。P5.js 有可能吗?
electron ×2
node.js ×2
angular ×1
javascript ×1
macos ×1
node-modules ×1
p5.js ×1
python ×1
shapes ×1
sudo ×1
tensorflow ×1