Skip to content

Commit 0a8799a

Browse files
Fix issue with spaces in pymusiclooper and update on validation
1 parent f3201fd commit 0a8799a

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

MSUScripter/MSUScripter.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
99
<ApplicationIcon>MSUScripterIcon.ico</ApplicationIcon>
1010
<PackageIcon>MSUScripterIcon.ico</PackageIcon>
11-
<Version>4.2.0</Version>
11+
<Version>4.2.1-beta.1</Version>
1212
<RuntimeFrameworkVersion>8.0.0</RuntimeFrameworkVersion>
1313
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
1414
<LangVersion>12</LangVersion>

MSUScripter/Services/ControlServices/PyMusicLooperPanelService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private void FilterResults()
145145

146146
public void TestPyMusicLooper()
147147
{
148-
if (!pyMusicLooperService.TestService(out string message, false))
148+
if (!pyMusicLooperService.TestService(out string message))
149149
{
150150
_model.Message = message;
151151
_model.DisplayGitHubLink = true;

MSUScripter/Services/ControlServices/SettingsWindowService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public bool ValidateMsuPcm()
3131

3232
public bool ValidatePyMusicLooper()
3333
{
34-
return pyMusicLooperService.TestService(out _, true);
34+
return pyMusicLooperService.TestService(out _, _model.PyMusicLooperPath);
3535
}
3636
}

MSUScripter/Services/PyMusicLooperService.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void ClearCache()
7676

7777
if (!_hasValidated)
7878
{
79-
if (!TestService(out message, false))
79+
if (!TestService(out message))
8080
{
8181
IsRunning = false;
8282
return null;
@@ -133,15 +133,20 @@ public void ClearCache()
133133
return loopPoints;
134134
}
135135

136-
public bool TestService(out string message, bool force)
136+
public bool TestService(out string message, string? testPath = null)
137137
{
138-
if (_hasValidated && !force)
138+
if (_hasValidated && testPath == null)
139139
{
140140
message = "";
141141
return true;
142142
}
143143

144-
if (!string.IsNullOrEmpty(_settings.PyMusicLooperPath) && File.Exists(_settings.PyMusicLooperPath))
144+
if (testPath != null)
145+
{
146+
_settings.PyMusicLooperPath = testPath;
147+
_pyMusicLooperCommand = string.Empty == testPath ? "pymusiclooper" : testPath;
148+
}
149+
else if (!string.IsNullOrEmpty(_settings.PyMusicLooperPath) && File.Exists(_settings.PyMusicLooperPath))
145150
{
146151
_pyMusicLooperCommand = _settings.PyMusicLooperPath;
147152
}

MSUScripter/Services/PythonCommandRunnerService.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Diagnostics;
3+
using System.IO;
34
using System.Runtime.InteropServices;
45
using System.Text;
56
using System.Threading;
@@ -108,12 +109,24 @@ private bool RunInternal(string command, string arguments, out string result, ou
108109

109110
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
110111
{
112+
var workingDirectory = "";
113+
if (System.IO.File.Exists(command))
114+
{
115+
workingDirectory = Directory.GetParent(command)?.FullName;
116+
if (!string.IsNullOrEmpty(workingDirectory))
117+
{
118+
var file = Path.GetFileName(command);
119+
innerCommand = $"{file} {arguments}";
120+
}
121+
}
122+
111123
procStartInfo= new ProcessStartInfo("cmd", "/c " + innerCommand)
112124
{
113125
RedirectStandardOutput = redirectOutput,
114126
RedirectStandardError = redirectOutput,
115127
UseShellExecute = false,
116-
CreateNoWindow = true
128+
CreateNoWindow = true,
129+
WorkingDirectory = workingDirectory
117130
};
118131
}
119132
else

0 commit comments

Comments
 (0)