Skip to content

Commit

Permalink
feat(saspy): check SASPy version when enabaling diagnostics
Browse files Browse the repository at this point in the history
Signed-off-by: Shuguang Sun <[email protected]>
  • Loading branch information
ShuguangSun committed Aug 30, 2024
1 parent 829ad69 commit 5be205d
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions client/src/connection/saspy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ run;
this._config.cfgname?.length > 0 ? this._config.cfgname : "";
const scriptContent = `
import saspy
from packaging.version import parse
_cfgname = "${cfgname}"
Expand All @@ -139,10 +140,13 @@ else:
try:
not sas
sas
except NameError:
raise Exception("Setup error")
enable_diagnostic = parse(saspy.__version__) >= parse("5.14.0")
enable_diagnostic
sas.HTML_Style = '${saspyHtmlStyle}'
vscode_saspy_code = r"""
Expand All @@ -154,6 +158,8 @@ if ll_init is not None:
print(ll_init['LOG'])
ll_init = None
print("${LineCodes.SessionCreatedCode}")
`;

this._shellProcess.stdin.write(scriptContent + "\n", this.onWriteComplete);
Expand All @@ -177,7 +183,7 @@ if ll_init is not None:
// print(ll_init['LOG'])
// ll_init = None

// `, this.onWriteComplete);
// `, this.onWriteComplete);

if (this._config.sasOptions?.length > 0) {
const sasOptsInput = `$sasOpts=${this.formatSASOptions(
Expand Down Expand Up @@ -225,17 +231,20 @@ ${codeWithEnd}
"""
`;

// console.log("codeToRun = " + codeToRun);

this._html5FileName = "";
this._shellProcess.stdin.write(codeToRun);
this._pollingForLogResults = true;
await this._shellProcess.stdin.write(
// Below SASPy V5.14.0, we can't get the log line type
// `ll=sas.submit(codeToRun, results='HTML')\n`,
// from SASPy V5.14.0, it provides an option to get line type in log
`ll=sas.submit(codeToRun, results='HTML', loglines=True)\n`,
`
if enable_diagnostic:
ll=sas.submit(codeToRun, results='HTML', loglines=True)
else:
ll=sas.submit(codeToRun, results='HTML')
`,
async (error) => {
await this.fetchLog();
if (error) {
Expand Down Expand Up @@ -303,8 +312,8 @@ ${codeWithEnd}
// Below SASPy V5.14.0, we can't get the log line type
// this._shellProcess.stdin.write(`print(ll['LOG'])\n`, this.onWriteComplete);
// from SASPy V5.14.0, it provides an option to get line type in log
// FIXME: The log of code for work directory should be diagnoticed together with
// the first run code, otherwise, as current implentation, the diagnotitics would
// FIXME: The log of code for work directory should be diagnoticed together with
// the first run code, otherwise, as current implentation, the diagnotitics would
// think the actual code has completed after parsing the log of code for working
// directory
// - update unsubscribe, or
Expand All @@ -315,8 +324,11 @@ if ll_init is not None:
print(ll_init['LOG'])
ll_init = None
for lln in ll["LOG"]:
print("${LineCodes.LogLineStarter}=", lln["type"], ":LINE=", lln["line"], sep="")
if enable_diagnostic:
for lln in ll["LOG"]:
print("${LineCodes.LogLineStarter}=", lln["type"], ":LINE=", lln["line"], sep="")
else:
print(ll['LOG'])
`,
this.onWriteComplete);
Expand Down

0 comments on commit 5be205d

Please sign in to comment.