Compare commits

...
10 Commits
Author SHA1 Message Date
itismadness 7be957b343 Install chardet to travis 2019-06-10 17:31:48 -08:00
itismadness 09bfa6a98b Fix handling of whipper logs under YAML 1.2 2019-06-11 14:13:21 +12:45
itismadness ddbc042897 Update composer dependencies 2019-06-11 03:49:10 +09:00
itismadness 3f81c3a91d Fix sudo usage for installing pip in Travis 2019-02-06 11:11:22 -05:00
itismadness 04d6d9cbef Use get-pip.py to install pip,setuptools,wheel on Travis 2019-02-06 11:06:59 -05:00
itismadness 752ec6af0a Install python3 and pip on Travis 2019-02-06 10:56:13 -05:00
itismadness 594add313f Bump to 0.8.2 2019-02-06 10:47:09 -05:00
Borewit fb05ef7b26 README: fix compile command using relative path (#7)
* Fix compile command using relative path

* Fix example using namespace

* More explicit code type declaration & include autoload
2019-01-02 12:09:53 -05:00
Borewit e462fdef45 #8 Prevent syntax error in unpacking nested arrays into loop variables (#9) 2019-01-02 12:09:38 -05:00
itismadness b38c25a13d Fix breaking when spaces in log name (closes #5) 2018-12-17 10:51:58 -05:00
8 changed files with 97 additions and 53 deletions

No files matched your search

+11 -2
View File
@@ -1,9 +1,10 @@
language: php
sudo: true
dist: trusty
dist: xenial
cache:
directories:
- $HOME/.cache/pip
- $HOME/.composer/cache
php:
@@ -19,11 +20,19 @@ matrix:
- php: nightly
before_install:
- composer install --ansi --prefer-dist --no-interaction --optimize-autoloader --no-suggest --no-progress
- sudo apt-get install python3
- wget https://bootstrap.pypa.io/get-pip.py
- sudo python3 get-pip.py
install:
- composer install --ansi --prefer-dist --no-interaction --optimize-autoloader --no-suggest --no-progress
- pip3 install --user chardet xld_logchecker eac_logchecker
script:
- bin/logchecker --version
- bin/logchecker --help
- bin/logchecker tests/logs/wgdbcm.log
- bin/logchecker tests/logs/xld_perfect.log
before_deploy:
- php -d phar.readonly=0 bin/compile
+10 -6
View File
@@ -33,7 +33,7 @@ file. Download this file, and then it can executed via CLI by running `php logch
Alternatively, if you `chmod +x logchecker.phar`, it can be executed directly by doing `./logchecker.phar`.
To install it globally, run:
```
```bash
mv logchecker.phar /usr/local/bin/logchecker
chmod +x /usr/local/bin/logchecker
```
@@ -75,7 +75,7 @@ Details :
```
### Code
```
```php
<?php
$logchecker = new OrpheusNET\Logchecker\Logchecker();
@@ -90,8 +90,12 @@ $ composer require orpheusnet/logchecker
```
### Usage
```
use OrpheusNET\Logchecker\Logchecker();
```php
<?php
require __DIR__ . '/vendor/autoload.php';
use OrpheusNET\Logchecker\Logchecker;
$logchecker = new Logchecker();
$logchecker->new_file('/path/to/log/file');
@@ -109,9 +113,9 @@ print("\nLog Text:\n{$log_text}");
To build your own phar, you can checkout this repository, and then
run the `bin/compile` script. To do this, run the following commands:
```
```bash
git clone https://github.com/OPSnet/Logchecker
cd Logchecker
composer install
php -d phar.readonly=0 /bin/compile
php -d phar.readonly=0 bin/compile
```
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "orpheusnet/logchecker",
"description": "Logchecker for validating logs generated from supported ripping programs (like EAC and XLD)",
"version": "0.8.1",
"version": "0.8.3",
"license": "Unlicense",
"type": "library",
"authors": [
Generated
+32 -29
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "165e83b0ccad187ade7bf2a38820cb4c",
"content-hash": "9ad854c65da76498f6a2af058812e332",
"packages": [
{
"name": "psr/log",
@@ -55,16 +55,16 @@
},
{
"name": "symfony/console",
"version": "v3.4.19",
"version": "v3.4.28",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "8f80fc39bbc3b7c47ee54ba7aa2653521ace94bb"
"reference": "8e1d1e406dd31727fa70cd5a99cda202e9d6a5c6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/8f80fc39bbc3b7c47ee54ba7aa2653521ace94bb",
"reference": "8f80fc39bbc3b7c47ee54ba7aa2653521ace94bb",
"url": "https://api.github.com/repos/symfony/console/zipball/8e1d1e406dd31727fa70cd5a99cda202e9d6a5c6",
"reference": "8e1d1e406dd31727fa70cd5a99cda202e9d6a5c6",
"shasum": ""
},
"require": {
@@ -76,6 +76,9 @@
"symfony/dependency-injection": "<3.4",
"symfony/process": "<3.3"
},
"provide": {
"psr/log-implementation": "1.0"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~3.3|~4.0",
@@ -85,7 +88,7 @@
"symfony/process": "~3.3|~4.0"
},
"suggest": {
"psr/log-implementation": "For using the console logger",
"psr/log": "For using the console logger",
"symfony/event-dispatcher": "",
"symfony/lock": "",
"symfony/process": ""
@@ -120,20 +123,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2018-11-26T12:48:07+00:00"
"time": "2019-05-09T08:42:51+00:00"
},
{
"name": "symfony/debug",
"version": "v3.4.19",
"version": "v3.4.28",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "2016b3eec2e49c127dd02d0ef44a35c53181560d"
"reference": "671fc55bd14800668b1d0a3708c3714940e30a8c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/2016b3eec2e49c127dd02d0ef44a35c53181560d",
"reference": "2016b3eec2e49c127dd02d0ef44a35c53181560d",
"url": "https://api.github.com/repos/symfony/debug/zipball/671fc55bd14800668b1d0a3708c3714940e30a8c",
"reference": "671fc55bd14800668b1d0a3708c3714940e30a8c",
"shasum": ""
},
"require": {
@@ -176,20 +179,20 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2018-11-11T19:48:54+00:00"
"time": "2019-05-18T13:32:47+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.10.0",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "e3d826245268269cd66f8326bd8bc066687b4a19"
"reference": "82ebae02209c21113908c229e9883c419720738a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19",
"reference": "e3d826245268269cd66f8326bd8bc066687b4a19",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
"reference": "82ebae02209c21113908c229e9883c419720738a",
"shasum": ""
},
"require": {
@@ -201,7 +204,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
"dev-master": "1.11-dev"
}
},
"autoload": {
@@ -234,20 +237,20 @@
"polyfill",
"portable"
],
"time": "2018-08-06T14:22:27+00:00"
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.10.0",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "c79c051f5b3a46be09205c73b80b346e4153e494"
"reference": "fe5e94c604826c35a32fa832f35bd036b6799609"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494",
"reference": "c79c051f5b3a46be09205c73b80b346e4153e494",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609",
"reference": "fe5e94c604826c35a32fa832f35bd036b6799609",
"shasum": ""
},
"require": {
@@ -259,7 +262,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
"dev-master": "1.11-dev"
}
},
"autoload": {
@@ -293,20 +296,20 @@
"portable",
"shim"
],
"time": "2018-09-21T13:07:52+00:00"
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "symfony/yaml",
"version": "v3.4.19",
"version": "v3.4.28",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "291e13d808bec481eab83f301f7bff3e699ef603"
"reference": "212a27b731e5bfb735679d1ffaac82bd6a1dc996"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/291e13d808bec481eab83f301f7bff3e699ef603",
"reference": "291e13d808bec481eab83f301f7bff3e699ef603",
"url": "https://api.github.com/repos/symfony/yaml/zipball/212a27b731e5bfb735679d1ffaac82bd6a1dc996",
"reference": "212a27b731e5bfb735679d1ffaac82bd6a1dc996",
"shasum": ""
},
"require": {
@@ -352,7 +355,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2018-11-11T19:48:54+00:00"
"time": "2019-03-25T07:48:46+00:00"
}
],
"packages-dev": [],
+1 -1
View File
@@ -44,4 +44,4 @@ for ($i = 1; $i < $rows->length; $i++) {
file_put_contents(__DIR__.'/../src/offsets.txt', implode("\n", $offsets));
print("Updating ".count($offsets)." drives\n");
print("Updating ".count($offsets)." drives\n");
+2
View File
@@ -28,6 +28,8 @@ class AnalyzeCommand extends Command {
$logchecker = new Logchecker();
$logchecker->new_file($filename);
list($score, $details, $checksum, $log_text) = $logchecker->parse();
$output->writeln('Ripper : ' . $logchecker->get_ripper());
$output->writeln('Version : ' . $logchecker->get_version());
$output->writeln('Score : ' . $score);
$output->writeln('Checksum: ' . ($checksum ? 'true' : 'false'));
+39 -13
View File
@@ -167,6 +167,17 @@ class Logchecker {
return $this->return_parse();
}
$this->RIPPER = 'whipper';
$this->Version = explode(" ", $Yaml['Log created by'])[1];
// Releases before this used octal numbers for tracks in the log which
// gets messed up in parsing and we lose track data (e.g. tracks 08 and
// 09 get merged into one entry).
if (empty($this->Version) || version_compare('0.7.3', $this->Version) === 1) {
$this->account('Logs must be produced by whipper 0.7.3+', 100);
return $this->return_parse();
}
if (!empty($Yaml['SHA-256 hash'])) {
$Hash = $Yaml['SHA-256 hash'];
$Lines = explode("\n", trim($this->Log));
@@ -217,15 +228,18 @@ class Logchecker {
}
$DefeatCache = $Yaml['Ripping phase information']['Defeat audio cache'];
if ($DefeatCache) {
$Value = 'Yes';
$Class = 'good';
if (is_string($DefeatCache)) {
$Value = (strtolower($DefeatCache) === 'yes') ? 'Yes' : 'No';
$Class = (strtolower($DefeatCache) === 'yes') ? 'good' : 'bad';
}
else {
$Value = 'No';
$Class = 'bad';
$this->account('"Defeat audio cache" should be yes', 10);
$Value = ($DefeatCache === true) ? 'true' : 'false';
$Class = ($DefeatCache === true) ? 'good' : 'bad';
}
if ($Class === 'bad') {
$this->account('"Defeat audio cache" should be Yes/true', 10);
}
$Yaml['Ripping phase information']['Defeat audio cache'] = "<span class='{$Class}'>{$Value}</span>";
foreach ($Yaml['Tracks'] as $Key => $Track) {
@@ -245,7 +259,7 @@ class Logchecker {
$this->Log .= "Ripping phase information:\n";
foreach ($Yaml['Ripping phase information'] as $Key => $Value) {
if (is_bool($Value)) {
$Value = ($Value) ? 'Yes' : 'No';
$Value = ($Value) ? 'true' : 'false';
}
$this->Log .= " {$Key}: {$Value}\n";
}
@@ -254,7 +268,7 @@ class Logchecker {
$this->Log .= "CD metadata:\n";
foreach ($Yaml['CD metadata'] as $Key => $Value) {
if (is_bool($Value)) {
$Value = ($Value) ? 'Yes' : 'No';
$Value = ($Value) ? 'true' : 'false';
}
$this->Log .= " {$Key}: {$Value}\n";
}
@@ -439,10 +453,14 @@ class Logchecker {
$GoodString = 'OK';
}
$CommandExists = Util::commandExists($Command);
$Out = shell_exec("{$Command} {$this->LogPath}");
if (Util::strposArray($Out, $BadStrings) !== false || strpos($Out, $GoodString) === false) {
$this->Checksum = false;
if (Util::commandExists($Command)) {
$Out = shell_exec("{$Command} ".escapeshellarg($this->LogPath));
if ($Out == null || Util::strposArray($Out, $BadStrings) !== false || strpos($Out, $GoodString) === false) {
$this->Checksum = false;
}
}
else {
$this->account("Could not find {$Command}, checksum not validated.", false, false, false, true);
}
}
@@ -1020,7 +1038,7 @@ class Logchecker {
$MatchedDrives[$i] = ['drives' => [], 'offsets' => []];
}
foreach ($this->AllDrives as [$Drive, $Offset]) {
foreach ($this->AllDrives as list($Drive, $Offset)) {
$Distance = levenshtein($Drive, $DriveName);
if ($Distance < 5) {
$MatchedDrives[$Distance]['drives'][] = $Drive;
@@ -1460,6 +1478,14 @@ class Logchecker {
);
}
function get_ripper() {
return $this->RIPPER;
}
function get_version() {
return $this->Version;
}
public static function get_accept_values() {
return ".txt,.TXT,.log,.LOG";
}
+1 -1
View File
@@ -3,7 +3,7 @@
namespace OrpheusNET\Logchecker;
class Util {
public static function commandExists($cmd) {
public static function commandExists(string $cmd) {
$where = substr(strtolower(PHP_OS), 0, 3) === 'win' ? 'where' : 'command -v';
exec("{$where} {$cmd} 2>/dev/null", $output, $return_var);