Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improves the plugin overall and adds "update the updater"

  • Loading branch information...
commit 0df8ebdcfb87602899664ae2d40ccf99d422c2c4 1 parent b45715c
Tomás Touceda authored
Showing with 80 additions and 15 deletions.
  1. +80 −15 thandy/thandy.js
View
95 thandy/thandy.js
@@ -9,44 +9,74 @@ var thandy = {
this.tab = null;
this.tab = this.buildGUI();
this.thandyProcess = new QProcess();
+ this.bootstrapUpdateProcess = new QProcess();
this.ts = new QTextStream(this.thandyProcess);
this.timer = new QTimer();
this.load();
- this.timer.start(1*1000*60);
this.timer['timeout()'].connect(this, this.doCheck);
+ if(this.chkPeriodicallyCheck.checkState() == Qt.Checked)
+ this.timer.start(1*1000*60*this.spnMin.value);
// this.doCheck();
this.thandyProcess['readyReadStandardOutput()'].connect(this, this.checkStdin);
this.thandyProcess['finished(int, QProcess::ExitStatus)'].connect(this, this.onFinished);
+ this.bootstrapUpdateProcess['readyReadStandardOutput()'].connect(this, this.debugStdin);
+ this.bootstrapUpdateProcess['finished(int, QProcess::ExitStatus)'].connect(this, this.onBootstrapUpdateFinished);
+
this.checking = false;
this.forceDownload = false;
this.ready_bundles = [];
+ this.do_downloads = [];
},
load: function() {
+ // PreiodicallyCheck = true/false
+ // CheckInterval = int (minutes)
+ // Download = true/false
+ // UpdaterPath = /path/to/updater/binary
+ // DataDir = /path/to/updater.conf (without the "updater.conf")
+ // BootstrapUpdateCmd = /path/to/ClientCli
+ // BootstrapUpdateParams = update,--controller-log-format,--install,/bundleinfo/bootstrapper/
+ // VidaliaBundle = "Vidalia Bundle"
+ // BootstrapBundle = "Bootstrapper"
+ // ThpDbRoot = ""
+ // ThpInstallRoot = ""
this.chkPeriodicallyCheck.setCheckState((this.tab.getSetting("PeriodicallyCheck", "true") == "true")?Qt.Checked:Qt.Unchecked);
this.spnMin.value = this.tab.getSetting("CheckInterval", 1);
this.chkDownload.setCheckState((this.tab.getSetting("Download", "true") == "true")?Qt.Checked:Qt.Unchecked);
this.updaterPath = this.tab.getSetting("UpdaterPath", "");
this.dataDir = this.tab.getSetting("DataDir", "");
+ this.bootstrapUpdateCmd = this.tab.getSetting("BootstrapUpdateCmd", "");
+ this.bootstrapUpdateParams = this.tab.getSetting("BootstrapUpdateParams", "").toString().split(",");
+ this.vidaliaBundle = this.tab.getSetting("VidaliaBundle", "Vidalia Bundle");
+ this.bootstrapBundle = this.tab.getSetting("BootstrapBundle", "Bootstrap");
+ this.thpDbRoot = this.tab.getSetting("ThpDbRoot", "");
+ this.thpInstallRoot = this.tab.getSetting("ThpInstallRoot", "");
},
save: function() {
this.tab.saveSetting("PeriodicallyCheck", (this.chkPeriodicallyCheck.checkState()==Qt.Checked)?"true":"false");
this.tab.saveSetting("Download", (this.chkDownload.checkState()==Qt.Checked)?"true":"false");
this.tab.saveSetting("CheckInterval", this.spnMin.value);
+
+ if(this.chkPeriodicallyCheck.checkState() == Qt.Checked)
+ this.timer.start(1*1000*60*this.spnMin.value);
},
doCheck: function() {
vdebug("Thandy@doCheck");
- if(this.checking)
+
+ // this.forceDownload makes it ignore the user saved setting
+ if(this.checking && !this.forceDownload)
return;
+ this.btnCheck.enabled = false;
this.checking = true;
-
+ this.timer.stop();
+
var params = ["--datadir", this.dataDir, "--check"]
if(!this.forceDownload && this.chkDownload.checkState() != Qt.Checked) {
params = params.concat(["--no-download"]);
@@ -62,24 +92,50 @@ var thandy = {
closeAndUpdate: function() {
vdebug("Thandy@closeAndUpdate");
var params = ["--datadir", this.dataDir];
- if(this.ready_bundles.indexOf("Vidalia Bundle"))
- params.concat(["--wait", "5"]);
- vdebug(this.updaterPath, params);
+ if(this.ready_bundles.indexOf(this.vidaliaBundle) != -1)
+ params = params.concat(["--wait", "5"]);
+
+ if(this.ready_bundles.indexOf(this.bootstrapBundle) != -1) {
+ this.ready_bundles.splice(this.ready_bundles.indexOf(this.bootstrapBundle), 1);
+ var e = new QProcessEnvironment();
+ e.insert("THP_DB_ROOT", this.thpDbRoot);
+ e.insert("THP_INSTALL_ROOT", this.thpInstallRoot);
+ this.bootstrapUpdateProcess.setProcessEnvironment(e);
+ this.bootstrapUpdateProcess.setReadChannel(QProcess.StandardOutput);
+ this.bootstrapUpdateProcess.start(this.bootstrapUpdateCmd,
+ this.bootstrapUpdateParams,
+ QIODevice.ReadOnly);
+ return
+ }
+
+
QProcess.startDetached(this.updaterPath + " " + params.join(" "));
- if(this.ready_bundles.indexOf("Vidalia Bundle"))
+ if(this.ready_bundles.indexOf(this.vidaliaBundle) != -1)
vidaliaApp.quit();
},
+ onBootstrapUpdateFinished: function(exitCode, exitStatus) {
+ vdebug("Thandy@onBootstrapUpdateFinished", exitCode, exitStatus);
+ this.doCheck();
+ },
+
onFinished: function(exitCode, exitStatus) {
vdebug("Thandy@onFinished");
for(var i = 0; i<this.ready_bundles.length; i++)
vdebug(this.ready_bundles[i]);
+ if(this.do_downloads.length > 0 && !this.forceDownload)
+ this.newDownload(this.do_downloads.toString());
if(this.ready_bundles.length > 0)
this.doUpdate(this.ready_bundles.toString());
+ this.do_downloads = [];
this.ready_bundles = [];
-
+ vdebug("Checking is false now");
this.checking = false;
this.forceDownload = false;
+
+ if(this.chkPeriodicallyCheck.checkState() == Qt.Checked)
+ this.timer.start(1*1000*60*this.spnMin.value);
+ this.btnCheck.enabled = false;
},
parseInteresting: function(what, what_inside, msg) {
@@ -136,7 +192,7 @@ var thandy = {
if(!this.forceDownload && this.chkDownload.checkState() != Qt.Checked) {
var file = this.parseInteresting("WANTFILE", "FILENAME", msg);
if(file != "")
- this.newDownload(file);
+ this.do_downloads = this.do_downloads.concat([file]);
}
// Ask whether to update things or not
// If we are ready to update
@@ -146,28 +202,37 @@ var thandy = {
},
doUpdate: function(name) {
- var ret = QMessageBox.question(0, "Do you want to update this bundle?",
- "The following bundles have an uptade: \n" + name + "\nDo you want to proceed?",
- QMessageBox.StandardButtons(QMessageBox.Yes, QMessageBox.No));
+ var ret = QMessageBox.question(0, "Do you want to update these bundles?",
+ "The following bundles have an uptade: \n" + name + "\nDo you want to proceed?",
+ QMessageBox.StandardButtons(QMessageBox.Yes, QMessageBox.No));
if(ret == QMessageBox.Yes) {
this.closeAndUpdate();
}
},
newDownload: function(name) {
- var ret = QMessageBox.question(0, "Do you want to download this file?",
- "The following file needs to be downloaded: \n" + name + "\nDo you want to proceed?",
- QMessageBox.StandardButtons(QMessageBox.Yes, QMessageBox.No));
+ var ret = QMessageBox.question(0, "Do you want to download these files?",
+ "The following files need to be downloaded: \n" + name + "\nDo you want to proceed?",
+ QMessageBox.StandardButtons(QMessageBox.Yes, QMessageBox.No));
if(ret == QMessageBox.Yes) {
+ // ignore the user saved config and download
this.forceDownload = true;
this.doCheck();
}
},
+ debugStdin: function() {
+ vdebug("Thandy@debugStdin");
+ vdebug(this.boostrapUpdateProcess.readAllStandardOutput());
+ },
+
checkStdin: function() {
vdebug("Thandy@checkStdin");
+ if(this.forceDownload)
+ return;
var list = this.ts.readAll().split("\n");
for(i = 0; i<list.length; i++) {
+ vdebug(list[i]);
this.findInteresting(list[i]);
}
},
Please sign in to comment.
Something went wrong with that request. Please try again.