tydeno / Ploto

A Windows PowerShell based Chia Plotting Manager. Lets you automatically spawn and move plots. Sends you notifications on the go.
MIT License
32 stars 5 forks source link

[BUG] - Ploto does not recognize european datetime formats #95

Closed tekstaker closed 3 years ago

tekstaker commented 3 years ago

Describe the bug Trying to run Ploto during a european date that won't transcribe into an (incorrect) American date will throw an error.

eg: 17/06/2021 is todays date in UK format. Ploto doesn't understand it because it's trying to use the first number as the month. The correct American date would be 06/17/2021.

tydeno commented 3 years ago

Thanks for reporting. I will need to look into it. Where do you get that error? Could you post the output here?

tydeno commented 3 years ago

Report by user:

I am getting this unusual error and have tried everything, even change regional settings from UK to USA but nothing works.....

Get-Date : Cannot bind parameter 'Date'. Cannot convert value "06/21/2021 00:28:09" to type "System.DateTime". Error:
"String was not recognized as a valid DateTime."
At C:\Users\User\Downloads\Ploto-main\Ploto-main\Ploto.psm1:2298 char:45
+             [datetime]$StartTime = Get-Date ($job.starttime)
+                                             ~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Date], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.GetDateCommand

Get-Date : Cannot bind parameter 'Date' to the target. Exception setting "Date": "Cannot convert null to type
"System.DateTime"."
At C:\Users\User\Downloads\Ploto-main\Ploto-main\Ploto.psm1:2312 char:33
+             EndDate = (Get-Date $StartTime).AddHours($completiontime)
+                                 ~~
    + CategoryInfo          : WriteError: (:) [Get-Date], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.GetDateCommand

Error executing Discord Webhook -> [The remote server returned an error: (404) Not Found.]!
At C:\Users\User\Downloads\Ploto-main\Ploto-main\Ploto.psm1:3699 char:21
+ ...             throw "Error executing Discord Webhook -> [$errorMessage] ...
+                 ~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Error executing...4) Not Found.]!:String) [], RuntimeException
    + FullyQualifiedErrorId : Error executing Discord Webhook -> [The remote server returned an error: (404) Not Found
   .]!
tydeno commented 3 years ago

Background

For some datetime reasons, Ploto has trouble removing aborted jobs upon launch. Upon my own observation, the full functionality is given, as Ploto will keep going, even with those ugly red lines.

The troubling lines of code are within then function Remove-AbortedPlotoJobs:

[datetime]$StartTime = Get-Date ($job.starttime)

$JobToReport = [PSCustomObject]@{
JobId     =  $job.jobid
StartTime = $job.Starttime
PlotId = $job.PlotId
ArgumentList = $job.ArgumentList
TempDrive = $job.TempDrive
OutDrive = $job.OutDrive
CompletionTime = $job.CompletionTime
CompletionTimeP1 = $job.CompletionTimeP1
CompletionTimeP2 = $job.CompletionTimeP2
CompletionTimeP3 = $job.CompletionTimeP3
CompletionTimeP4 = $job.CompletionTimeP4
EndDate = (Get-Date $StartTime).AddHours($completiontime)
}

Where job is an instance of $JobsToAbort: $JobsToAbort = Get-PlotoJobs | Where-Object {$_.Status -eq "Aborted"}

Workaround

Flush your logs in C:\Users\Yanik\.chia\mainnet\plotter (replace 'Tydeno' with the user you run your chia instance). This like always helps with Ploto.

If you have any left overs of aborted jobs on your drives (.tmp files) you need to remove the manually. Afterwards, Ploto should be able to start normally, as there are no jobs that could generate an error.

tydeno commented 3 years ago

Removed Start/EndTime calc from Remove-AbortedPlotoJobs. It's not needed anyway there.