Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

12
LINES

< > BotCompany Repo | #1014297 // parseDiskSpacePercentage - parse output of Disk Space Bot - return % full (including inodes)

JavaX fragment (include)

1  
static double parseDiskSpacePercentage(S s) {
2  
  L<S> l = regexpGroups("(\\d+) MB free of (\\d+) MB\\.", s);
3  
  if (empty(l)) ret -1;
4  
  double ratio = 1-doubleRatio(parseInt(first(l)), parseInt(second(l)));
5  
  l = regexpGroups("Free inodes: (\\d+)K/(\\d+)K", s);
6  
  if (nempty(l)) { 
7  
    double ratio2 = 1-doubleRatio(parseInt(first(l)), parseInt(second(l)));
8  
    print("ratio=" + ratio + ", ratio2=" + ratio2);
9  
    ratio = max(ratio, ratio2);
10  
  }
11  
  ret ratio*100;
12  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1014297
Snippet name: parseDiskSpacePercentage - parse output of Disk Space Bot - return % full (including inodes)
Eternal ID of this version: #1014297/8
Text MD5: 086a45f3cfa8d94e1c6ab6d7a6eedaad
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-14 18:46:36
Source code size: 473 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 532 / 538
Version history: 7 change(s)
Referenced in: [show references]