Skip to content

Commit

Permalink
unix path problems
Browse files Browse the repository at this point in the history
  • Loading branch information
mjoppich committed Jan 12, 2017
1 parent 5501260 commit 719dc8d
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 26 deletions.
3 changes: 0 additions & 3 deletions about.md

This file was deleted.

19 changes: 15 additions & 4 deletions src/app/ProcessLauncher.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ class ProcessLauncher : public QObject
return NULL;
}

QString startBlocking(uint32_t iWaitMSec = 10000)
{
this->start();

m_pProcess->waitForFinished( iWaitMSec );

QString sOut( m_pProcess->readAllStandardOutput() );

return sOut;
}

bool start()
{

Expand Down Expand Up @@ -326,8 +337,8 @@ public slots:
size_t iOffSet = (sString.at(i) == ' ') ? 0 : 1;

std::string sPart = sString.substr(iLastArgPartStart, i-iLastArgPartStart+iOffSet);
//if (sPart[0] == sPart[sPart.size()-1])
// sPart = sPart.substr(1,sPart.size()-2);
if ((sPart[0] == sPart[sPart.size()-1]) && ( (sPart[0] == '\"' ) || ( sPart[0] == '\'')))
sPart = sPart.substr(1,sPart.size()-2);

QString sQPart(sPart.c_str());
sQPart = sQPart.trimmed();
Expand All @@ -337,8 +348,8 @@ public slots:

std::cout << sQPart.toStdString() << std::endl;

if (sPart.size() > 0)
vArgsList.append( sQPart );
//if (sPart.size() > 0)
vArgsList.append( sQPart );

iLastArgPartStart = i+1;
}
Expand Down
6 changes: 6 additions & 0 deletions src/bioGUIapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ bioGUIapp::bioGUIapp(int& argc, char** argv)
: QApplication(argc, (char**)argv)
{

QCoreApplication::setApplicationName("bioGUI");
std::cerr << "Launching " << QCoreApplication::applicationName().toStdString() << std::endl;


std::cerr << "Main Application currently in dir: " << std::endl;
std::cerr << QDir::currentPath().toStdString() << std::endl;



this->loadInitFile(QDir::currentPath());

/*
Expand Down
44 changes: 43 additions & 1 deletion src/parsing/nodes/ExecutionEnvNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

#include <QNetworkInterface>
#include <QAbstractSocket>
#include <QtCore/QStandardPaths>
#include <src/app/ProcessLauncher.h>
#include <QtCore/QCoreApplication>
#include "ExecutionNode.h"

class ExecutionEnvNode : public ExecutionNode {
Expand All @@ -33,6 +36,7 @@ class ExecutionEnvNode : public ExecutionNode {
{

m_sGet = this->getDomElementAttribute(pElement, "GET", "");
m_sToWSL = this->getDomElementAttribute(pElement, "wsl", "false");


}
Expand Down Expand Up @@ -83,9 +87,25 @@ class ExecutionEnvNode : public ExecutionNode {

}

std::string getOS()
std::string getOS(std::map< std::string, ExecutionNode*>* pID2Node = NULL,
std::map<std::string, std::string>* pInputID2Value = NULL,
std::map<std::string, QWidget*>* pInputID2Widget = NULL)
{


bool bWSL = false;

if ((pID2Node != NULL) && (pInputID2Value != NULL) && (pInputID2Widget != NULL))
{
bWSL = this->checkWSL(m_sToWSL, pID2Node, pInputID2Value, pInputID2Widget);
}

if (bWSL)
{
// TODO make this return WSL?
return "LINUX";
}

if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
return "WINDOWS";

Expand All @@ -102,6 +122,8 @@ class ExecutionEnvNode : public ExecutionNode {
std::map<std::string, QWidget*>* pInputID2Widget) {


bool bWSL = this->checkWSL(m_sToWSL, pID2Node, pInputID2Value, pInputID2Widget);

std::string sResult;

if (m_sGet.compare("IP", Qt::CaseInsensitive) == 0)
Expand Down Expand Up @@ -151,6 +173,25 @@ class ExecutionEnvNode : public ExecutionNode {
return this->getOS();
}

if (m_sGet.compare("DATADIR", Qt::CaseInsensitive) == 0)
{

if (!bWSL)
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation).toStdString();

// we are on WSL
ProcessLauncher* pLauncher = new ProcessLauncher("echo", "~", true);
QString sQHome = pLauncher->startBlocking();

// exec in WSL "echo ~"
std::string sHome = sQHome.toStdString() + "/";

sHome += ".local/share/" + QCoreApplication::applicationName().toStdString();

return sHome;

}

return sResult;

}
Expand All @@ -163,6 +204,7 @@ class ExecutionEnvNode : public ExecutionNode {
}

QString m_sGet;
QString m_sToWSL;

};

Expand Down
24 changes: 24 additions & 0 deletions src/parsing/nodes/ExecutionNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,30 @@ class ExecutionNode {

}

bool checkWSL(QString& sWSLStr,
std::map< std::string, ExecutionNode*>* pID2Node,
std::map<std::string, std::string>* pInputID2Value,
std::map<std::string, QWidget*>* pInputID2Widget )
{
/*
* Are we relocating for WSL?
*
* */
bool bWSL = false;
if (sWSLStr.size() > 0)
{

std::string sValue = this->getNodeValueOrValue(sWSLStr.toStdString(), sWSLStr.toStdString(), pID2Node, pInputID2Value, pInputID2Widget );

if (QString(sValue.c_str()).compare("TRUE", Qt::CaseInsensitive) == 0)
{
bWSL = true;
}
}

return bWSL;
}

std::vector<std::string> getAcceptedAttributes()
{
std::vector<std::string> vReturnAttribs;
Expand Down
16 changes: 1 addition & 15 deletions src/parsing/nodes/ExecutionPathRelocateNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,7 @@ class ExecutionPathRelocateNode : public ExecutionNode {

bool bMakeUnix = m_bMakeUnix;

/*
* Are we relocating for WSL?
*
* */
bool bWSL = false;
if (m_sToWSL.size() > 0)
{

std::string sValue = this->getNodeValueOrValue(m_sToWSL.toStdString(), m_sToWSL.toStdString(), pID2Node, pInputID2Value, pInputID2Widget );

if (QString(sValue.c_str()).compare("TRUE", Qt::CaseInsensitive) == 0)
{
bWSL = true;
}
}
bool bWSL = this->checkWSL(m_sToWSL, pID2Node, pInputID2Value, pInputID2Widget);

/*What should be relocated?
* */
Expand Down
22 changes: 19 additions & 3 deletions templates/WSL_install.gui
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@
<group title="Install Options">
<label>Install Program to WSL?</label>
<checkbox id="WSLsel" value="true" selectonwindows="true">Use WSL?</checkbox>
<label>Install Location:</label>
<input id="instpath">~/bioGUI/progs/</input>

<groupbox id="user_sel_instpath" title="Install Location" exclusive="true">

<checkbox id="loc_datadir" value="data" selected="true">Install programs in User Data Dir</checkbox>
<checkbox id="loc_spec" value="spec"> <input id="loc_spec_user">/usr/local/</input></checkbox>

</groupbox>


<label>sudo Password</label>
<input id="sudopw" type="password"></input>

Expand Down Expand Up @@ -48,10 +55,19 @@
</if>

<env id="localip" get="IPv4"/>
<env id="loc_appdata" get="DATADIR" wsl="WSLsel"/>

<if id="user_instpath" comp="EQUALS" value1="user_sel_instpath" value2="data">
<value from="loc_appdata"/>
<else>
<value from="loc_spec_user"/>
</else>
</if>


<add id="cl" sep=" ">
<value from="prog_wsl"/>
<value from="instpath"/>
<value from="user_instpath"/>
<add sep="">
<const>&quot;</const>
<value from="sudopw"/>
Expand Down

0 comments on commit 719dc8d

Please sign in to comment.