linny-r 1.1.15 → 1.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linny-r",
3
- "version": "1.1.15",
3
+ "version": "1.1.16",
4
4
  "description": "Executable graphical language with WYSIWYG editor for MILP models",
5
5
  "main": "server.js",
6
6
  "scripts": {
package/server.js CHANGED
@@ -77,7 +77,8 @@ function getVersionInfo() {
77
77
  }
78
78
  try {
79
79
  const
80
- json = child_process.execSync('npm show linny-r time version --json'),
80
+ json = child_process.execSync(
81
+ 'npm show linny-r time version --json', {timeout: 1000}),
81
82
  obj = JSON.parse(json);
82
83
  info.latest = obj.version;
83
84
  info.latest_time = new Date(Date.parse(obj.time[info.latest]));
@@ -433,7 +434,7 @@ function repositoryByName(name) {
433
434
  while(rbn.length < 2) rbn.push('');
434
435
  if(rbn[0] === name) return rbn;
435
436
  }
436
- console.log(`ERROR: Repository "${name}" not found`);
437
+ console.log(`ERROR: Repository "${name}" not registered on this computer`);
437
438
  return false;
438
439
  }
439
440
 
@@ -485,7 +486,7 @@ function repoAdd(res, sp) {
485
486
  // Error callback function is used twice, so define it here
486
487
  const noConnection = (error, res) => {
487
488
  console.log(error);
488
- servePlainText(res, 'ERROR: Failed to connect to ' + url);
489
+ servePlainText(res, connectionErrorText('Failed to connect to ' + url));
489
490
  };
490
491
  // Verify that the URL points to a Linny-R repository
491
492
  postRequest(url, {action: 'id'},
@@ -596,8 +597,8 @@ function repoDir(res, rname) {
596
597
  // The `on_error` function
597
598
  (error, res) => {
598
599
  console.log(error);
599
- servePlainText(res,
600
- `ERROR: Failed to access remote repository "${rname}"`);
600
+ servePlainText(res, connectionErrorText(
601
+ `Failed to access remote repository "${rname}"`));
601
602
  },
602
603
  res);
603
604
  } else {
@@ -751,7 +752,7 @@ function repoAccess(res, rname, rtoken) {
751
752
  // The `on_error` function
752
753
  (error, res) => {
753
754
  console.log(error);
754
- servePlainText(res, 'ERROR: Failed to connect to' + r[1]);
755
+ servePlainText(res, connectionErrorText('Failed to connect to' + r[1]));
755
756
  },
756
757
  res);
757
758
  }
@@ -808,7 +809,7 @@ function repoStore(res, rname, mname, mxml) {
808
809
  // The `on_error` function
809
810
  (error, res) => {
810
811
  console.log(error);
811
- servePlainText(res, 'ERROR: Failed to connect to' + r[1]);
812
+ servePlainText(res, connectionErrorText('Failed to connect to' + r[1]));
812
813
  },
813
814
  res);
814
815
  } else {
@@ -870,7 +871,7 @@ function loadData(res, url) {
870
871
  getTextFromURL(url,
871
872
  (data, res) => servePlainText(res, data),
872
873
  (error, res) => servePlainText(res,
873
- `ERROR: Failed to get data from <tt>${url}</tt>`),
874
+ connectionErrorText(`Failed to get data from <tt>${url}</tt>`)),
874
875
  res);
875
876
  } catch(err) {
876
877
  console.log(err);
@@ -1378,6 +1379,10 @@ function formData(obj) {
1378
1379
  return fields.join('&');
1379
1380
  }
1380
1381
 
1382
+ function connectionErrorText(msg) {
1383
+ return 'WARNING: ' + msg + ' - Please check your internet connection';
1384
+ }
1385
+
1381
1386
  //
1382
1387
  // Functions used during initialization
1383
1388
  //
@@ -2019,10 +2019,9 @@ class LinnyRModel {
2019
2019
  this.timeout_period = Math.max(0,
2020
2020
  safeStrToInt(nodeContentByTag(node, 'timeout-period')));
2021
2021
  // Legacy models have tag "optimization-period" instead of "block-length"
2022
- const bl_tag = nodeContentByTag(node, 'block-length') ||
2022
+ const bl_str = nodeContentByTag(node, 'block-length') ||
2023
2023
  nodeContentByTag(node, 'optimization-period');
2024
- this.block_length = Math.max(1,
2025
- safeStrToInt(nodeContentByTag(node, bl_tag)));
2024
+ this.block_length = Math.max(1, safeStrToInt(node, bl_str));
2026
2025
  this.start_period = Math.max(1,
2027
2026
  safeStrToInt(nodeContentByTag(node, 'start-period')));
2028
2027
  this.end_period = Math.max(1,