new execution line format
This commit is contained in:
parent
65ec98daff
commit
c955e6a8f8
@ -60,15 +60,15 @@ However, if you choose `Script` option, then you cannot provide URL of your feed
|
||||
|
||||
Any errors in your script must be written to **error output**.
|
||||
|
||||
Note that you must provide full execution line to your custom script, including interpreter binary path and name and all that must be written in special format `<interpreter>#<arguments>`. The `#` character is there to separate interpreter from its arguments.
|
||||
Note that you must provide full execution line to your custom script, including interpreter binary path and name and all that must be written in special format `<interpreter>#<argument1>#<argument2>#....`. The `#` character is there to separate interpreter and individual arguments.
|
||||
|
||||
Interpreter must be provided in all cases, arguments do not have to be. For example `bash.exe#` is valid execution line, as well as `bash#-C "cat feed.atom"`. Note the difference in interpreter's binary name suffix. Some examples of valid and tested execution lines are:
|
||||
Interpreter must be provided in all cases, arguments do not have to be. For example `bash.exe#` is valid execution line, as well as `bash#-c#cat feed.atom`. Note the difference in interpreter's binary name suffix. Also be very carefuly about arguments quoting. Some examples of valid and tested execution lines are:
|
||||
|
||||
| Command | Explanation |
|
||||
|---------|-------------|
|
||||
| `bash#-c "curl 'https://github.com/martinrotter.atom'"` | Downloads ATOM feed file with Bash and Curl. |
|
||||
| `Powershell#"Invoke-WebRequest 'https://github.com/martinrotter.atom' \| Select-Object -ExpandProperty Content"` | Downloads ATOM feed file with Powershell. |
|
||||
| `php#tweeper.php -v 0 https://twitter.com/NSACareers` | Scrape Twitter RSS feed file with [Tweeper](https://git.ao2.it/tweeper.git). Tweeper is utility which is able to produce RSS feed from Twitter and other similar social platforms. |
|
||||
| `bash#-c#"curl https://github.com/martinrotter.atom"` | Downloads ATOM feed file with Bash and Curl. |
|
||||
| `Powershell#Invoke-WebRequest 'https://github.com/martinrotter.atom' \| Select-Object -ExpandProperty Content` | Downloads ATOM feed file with Powershell. |
|
||||
| `php#tweeper.php#-v#0#https://twitter.com/NSACareers` | Scrape Twitter RSS feed file with [Tweeper](https://git.ao2.it/tweeper.git). Tweeper is utility which is able to produce RSS feed from Twitter and other similar social platforms. |
|
||||
|
||||
<img src="images/scrape-source.png" width="50%">
|
||||
|
||||
@ -88,4 +88,4 @@ Typical post-processing filter might do things like advanced CSS formatting of f
|
||||
|
||||
| Command | Explanation |
|
||||
|---------|-------------|
|
||||
| `bash#-c "xmllint --format -"` | Pretty-print input XML feed data. |
|
||||
| `bash#-c#xmllint --format -` | Pretty-print input XML feed data. |
|
@ -657,20 +657,19 @@ QList<Message> StandardFeed::obtainNewMessages(bool* error_during_obtaining) {
|
||||
return messages;
|
||||
}
|
||||
|
||||
QPair<QString, QString> StandardFeed::prepareExecutionLine(const QString& execution_line) {
|
||||
QStringList StandardFeed::prepareExecutionLine(const QString& execution_line) {
|
||||
auto split_exec = execution_line.split('#', Qt::SplitBehaviorFlags::KeepEmptyParts);
|
||||
|
||||
if (split_exec.size() != 2) {
|
||||
if (split_exec.size() <= 1) {
|
||||
throw ScriptException(ScriptException::Reason::ExecutionLineInvalid);
|
||||
}
|
||||
|
||||
auto user_data_folder = qApp->userDataFolder();
|
||||
|
||||
return { split_exec[0].replace(EXECUTION_LINE_USER_DATA_PLACEHOLDER, user_data_folder),
|
||||
split_exec[1].replace(EXECUTION_LINE_USER_DATA_PLACEHOLDER, user_data_folder) };
|
||||
return split_exec.replaceInStrings(EXECUTION_LINE_USER_DATA_PLACEHOLDER, user_data_folder);
|
||||
}
|
||||
|
||||
QString StandardFeed::runScriptProcess(const QPair<QString, QString>& cmd_args, const QString& working_directory,
|
||||
QString StandardFeed::runScriptProcess(const QStringList& cmd_args, const QString& working_directory,
|
||||
int run_timeout, bool provide_input, const QString& input) {
|
||||
QProcess process;
|
||||
|
||||
@ -681,13 +680,8 @@ QString StandardFeed::runScriptProcess(const QPair<QString, QString>& cmd_args,
|
||||
process.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
|
||||
process.setProcessChannelMode(QProcess::ProcessChannelMode::SeparateChannels);
|
||||
process.setWorkingDirectory(working_directory);
|
||||
process.setProgram(cmd_args.first);
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
process.setNativeArguments(cmd_args.second);
|
||||
#else
|
||||
process.setArguments({ cmd_args.second });
|
||||
#endif
|
||||
process.setProgram(cmd_args.at(0));
|
||||
process.setArguments(cmd_args.mid(1));
|
||||
|
||||
if (!process.open()) {
|
||||
switch (process.error()) {
|
||||
|
@ -78,7 +78,7 @@ class StandardFeed : public Feed {
|
||||
|
||||
QList<Message> obtainNewMessages(bool* error_during_obtaining);
|
||||
|
||||
static QPair<QString, QString> prepareExecutionLine(const QString& execution_line);
|
||||
static QStringList prepareExecutionLine(const QString& execution_line);
|
||||
static QString generateFeedFileWithScript(const QString& execution_line, int run_timeout);
|
||||
static QString postProcessFeedFileWithScript(const QString& execution_line, const QString raw_feed_data, int run_timeout);
|
||||
|
||||
@ -103,7 +103,7 @@ class StandardFeed : public Feed {
|
||||
void fetchMetadataForItself();
|
||||
|
||||
private:
|
||||
static QString runScriptProcess(const QPair<QString, QString>& cmd_args, const QString& working_directory,
|
||||
static QString runScriptProcess(const QStringList& cmd_args, const QString& working_directory,
|
||||
int run_timeout, bool provide_input, const QString& input = {});
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user