From c3692381a9a2fd4cd94cede8ab0224de849ccbab Mon Sep 17 00:00:00 2001 From: dmacias72 Date: Wed, 17 Feb 2016 02:56:06 -0700 Subject: [PATCH] - remove curl progress bar - separate plugin depends by comma - only show update status of selected packages when processing --- .../emhttp/plugins/NerdPack/event/started | 2 - .../NerdPack/include/DownloadHelpers.php | 42 +------------------ .../plugins/NerdPack/include/PackageQuery.php | 5 ++- .../plugins/NerdPack/scripts/packagemanager | 10 +++-- 4 files changed, 11 insertions(+), 48 deletions(-) delete mode 100755 source/NerdPack/usr/local/emhttp/plugins/NerdPack/event/started mode change 100755 => 100644 source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/event/started b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/event/started deleted file mode 100755 index b6d9c967..00000000 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/event/started +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager --quiet diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php index bd3e70e9..298a1a09 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php @@ -1,42 +1,4 @@ $previousProgress) { - $previousProgress = $progress; - $pct = (double)($progress / 100); - $bar = round($pct * 30); - $pct_disp = number_format($pct * 100, 0); - $status_bar = "\r["; - $status_bar .= str_repeat("|", $bar); - - if ($bar < 30) { - $status_bar .= ">"; - $status_bar .= str_repeat("-", 30 - $bar); - } else { - $status_bar .= "|"; - } - - $status_bar .= "] $pct_disp%"; - - echo $status_bar; - ob_flush(); - - if ($progress == 100) { - echo "\n"; - } - } - ob_end_flush(); -} - // Download a file from given url function get_file_from_url($file, $url) { $chfile = fopen($file, 'w'); @@ -44,10 +6,10 @@ function get_file_from_url($file, $url) { $ch_vers = curl_version(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($ch, CURLOPT_TIMEOUT, 3600); - curl_setopt($ch, CURLOPT_NOPROGRESS, false); +curl_setopt($ch, CURLOPT_NOPROGRESS, true); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, 'curl/'.$ch_vers['version']); - curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'progress_bar'); + //curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'progress_bar'); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FILE, $chfile); curl_exec($ch); diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php index 6726f2d5..4324de1b 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php @@ -29,11 +29,12 @@ foreach ($pkgs_github_array as $pkg_github) { $plugins = []; exec("cd /boot/config/plugins ; find *.plg | xargs grep '${pkg_github['name']}' -sl",$plugins); - $pkg_plgs = ""; + $pkg_plgs = '--'; if ($plugins){ foreach ($plugins as $plugin){ - $pkg_plgs .= pathinfo($plugin, PATHINFO_FILENAME)." "; + $pkg_plgs .= pathinfo($plugin, PATHINFO_FILENAME).', '; } + $pkg_plgs = substr($pkg_plgs, 2, -2); } $pkg = [ diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager old mode 100755 new mode 100644 index 9e0f4d71..b2b7d4af --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager @@ -64,9 +64,9 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa if ($plugins){ $plg_msg = "$pkg_name used by plugin: "; foreach ($plugins as $plugin){ - $plg_msg .= pathinfo($plugin, PATHINFO_FILENAME)." "; + $plg_msg .= pathinfo($plugin, PATHINFO_FILENAME).", "; } - logger($plg_msg); + logger(substr($plg_msg, 0, -2)); } if ($pkg_pref == 'yes') { @@ -116,8 +116,10 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa shell_exec($pkg_cmd); //$output = shell_exec($pkg_cmd); //logger($output); - } else - logger("$pkg_name package up to date", $argq); + } else { + if ($pkg_pref == 'yes') + logger("$pkg_name package up to date", $argq); + } } logger('All packages processed...');