Compare commits

...
10 Commits
Author SHA1 Message Date
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
itismadness bd168e98b1 Bump to 0.8.1 2018-11-29 22:33:32 -05:00
itismadness ec4d49f690 Use command -v for checking for programs 2018-11-29 22:32:33 -05:00
itismadness 5a6a22cfbe Update readme 2018-11-29 21:30:21 -05:00
7 changed files with 90 additions and 37 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 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
+62 -25
View File
@@ -15,39 +15,32 @@ setting up the necessary programs to validate the checksum, see below for the gi
## Requirements
* PHP 7.0+
* Python3.4+
## Optional Requirements
* Python 3.5+
* [chardet](https://github.com/chardet/chardet)
* [eac_logchecker.py](https://github.com/OPSnet/eac_logchecker.py)
* [xld_logchecker.py](https://github.com/OPSnet/xld_logchecker.py)
## Installation
```
$ composer require orpheusnet/logchecker
$ pip3 install chardet eac-logchecker xld-logchecker
```
## Usage
### CLI
## Standalone
### Installation
Go to our [releases](https://github.com/OPSnet/Logchecker/releases) and grab the logchecker.phar
file. Download this file, and then it can executed via CLI by running `php logchecker.phar`.
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
```
$ logchecker list
Logchecker by Orpheus 0.5.0
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-V, --version Display this application version
Available commands:
analyze analyze log file
help Displays help for a command
list Lists commands
$ logchecker analyze --help
Description:
analyze log file
### Usage
```
$ logchecker --help
Usage:
analyze [options] [--] <file>
@@ -57,11 +50,18 @@ Arguments:
Options:
--output Print the HTML log text
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-file, --out=OUT File to write HTML log text to
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
This command analyzes a log file
$ logchecker analyze tests/logs/wgdbcm.log
$ logchecker tests/logs/wgdbcm.log
Score : 57
Checksum: false
Details :
@@ -75,10 +75,47 @@ Details :
```
### Code
```
```php
<?php
$logchecker = new OrpheusNET\Logchecker\Logchecker();
$logchecker->add_file('path/to/file.log');
list($score, $details, $checksum, $log_text) = $logchecker->parse();
```
## Library Usage
### Installation
```
$ composer require orpheusnet/logchecker
```
### Usage
```php
<?php
require __DIR__ . '/vendor/autoload.php';
use OrpheusNET\Logchecker\Logchecker;
$logchecker = new Logchecker();
$logchecker->new_file('/path/to/log/file');
list($score, $details, $checksum, $log_text) = $logchecker->parse();
print('Score: ' . $score . "\n");
print('Checksum: ' . ($checksum ? 'true' : 'false') . "\n");
print("\nDetails:\n");
foreach ($details as $detail) {
print(" {$detail}\n");
}
print("\nLog Text:\n{$log_text}");
```
## Building
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
```
+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.0",
"version": "0.8.2",
"license": "Unlicense",
"type": "library",
"authors": [
+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 -1
View File
@@ -15,11 +15,12 @@ class Chardet {
foreach ($this->executables as $executable) {
if (Util::commandExists($executable)) {
$this->executable = $executable;
break;
}
}
if ($this->executable === null) {
throw new \RuntimeException('Chardet not installed');
throw new \RuntimeException('chardet not installed');
}
}
+9 -5
View File
@@ -439,10 +439,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 +1024,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;
+4 -2
View File
@@ -4,8 +4,10 @@ namespace OrpheusNET\Logchecker;
class Util {
public static function commandExists($cmd) {
$return = shell_exec(sprintf("which %s", escapeshellarg($cmd)));
return !empty($return);
$where = substr(strtolower(PHP_OS), 0, 3) === 'win' ? 'where' : 'command -v';
exec("{$where} {$cmd} 2>/dev/null", $output, $return_var);
return $return_var === 0;
}
public static function strposArray(string $haystack, array $needles) {