File: store_json_module_data

package info (click to toggle)
lmod 8.7.60-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 63,008 kB
  • sloc: sh: 6,266; makefile: 2,837; ansic: 1,513; tcl: 1,382; python: 1,050; csh: 112
file content (35 lines) | stat: -rwxr-xr-x 637 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
# -*- python -*-
from __future__ import print_function
import os, sys, re, time, json
from LMODdb import LMODdb

def syshost(name):
  hostA = name.split('.')
  idx   = 1
  if (len(hostA) < 2):
    idx = 0
  return hostA[idx]

def main():

  ConfigBaseNm = "lmod_db"
  ConfigFn     = ConfigBaseNm + ".conf"

  lmod = LMODdb(ConfigFn)

  f = open(sys.argv[1],"r")
  j = 0
  for line in f:
    j += 1
    line  = line.rstrip("\n")
    dataT = json.loads(line)
    lmod.data_to_db(dataT)
    if (j % 1000000 == 0):
      print (".",end = "")
      sys.stdout.flush()

  f.close()


if ( __name__ == '__main__'): main()