diff --git a/javascript/system-info.js b/javascript/system-info.js index 84edb92..7acb4ae 100644 --- a/javascript/system-info.js +++ b/javascript/system-info.js @@ -21,7 +21,7 @@ const colorRangeMap = $.range_map({ '81:90': '#7c2d12', '91:100': '#6c2e12', }); -const sparklineConfig = { type: 'bar', height: '100px', barWidth: '3px', barSpacing: '1px', disableInteraction: true, chartRangeMin: 0, chartRangeMax: 100, disableHiddenCheck: true, colorMap: colorRangeMap, fillColor: false }; +const sparklineConfig = { type: 'bar', height: '100px', barWidth: 3, barSpacing: 1, disableInteraction: true, chartRangeMin: 0, chartRangeMax: 100, disableHiddenCheck: true, colorMap: colorRangeMap, fillColor: false }; function refresh_info() { const btn = gradioApp().getElementById('system_info_tab_refresh_btn'); // we could cache this dom element @@ -44,7 +44,7 @@ function receive_system_info(data) { loadData.push(data?.memory?.utilization || 0); const tab = gradioApp().getElementById('tab_system') || gradioApp().getElementById('tabs'); if (!tab) return; - sparklineConfig.barWidth = Math.floor(tab.clientWidth - 20) / data_length / 2; + sparklineConfig.barWidth = Math.max(1, Math.floor(tab.clientWidth - 20) / data_length / 2 - sparklineConfig.barSpacing); $('#si-sparkline-load').sparkline(loadData, sparklineConfig); if (memoData.length > data_length) memoData.shift(); diff --git a/scripts/system-info.py b/scripts/system-info.py index 1e2a527..cb05070 100644 --- a/scripts/system-info.py +++ b/scripts/system-info.py @@ -245,17 +245,20 @@ def get_libs(): def get_repos(): - repos = {} - for key, val in paths.paths.items(): - try: - cmd = f'git -C {val} log --pretty=format:"%h %ad" -1 --date=short' - res = subprocess.run(f'{cmd} {val}', stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=True, check=True) - stdout = res.stdout.decode(encoding = 'utf8', errors='ignore') if len(res.stdout) > 0 else '' - words = stdout.split(' ') - repos[key] = f'[{words[0]}] {words[1]}' - except Exception: - repos[key] = '(unknown)' - return repos + try: + repos = {} + for key, val in paths.paths.items(): + try: + cmd = f'git -C {val} log --pretty=format:"%h %ad" -1 --date=short' + res = subprocess.run(f'{cmd} {val}', stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=True, check=True) + stdout = res.stdout.decode(encoding = 'utf8', errors='ignore') if len(res.stdout) > 0 else '' + words = stdout.split(' ') + repos[key] = f'[{words[0]}] {words[1]}' + except Exception: + repos[key] = '(unknown)' + return repos + except Exception as e: + return { 'error': e } def get_platform():