Example #1
0
    def dashboard(self):
        from procfs_reader import entries, proc_uptime, disk_free, git_hash
        from grp import getgrall, getgrgid
        from pwd import getpwnam
        from stock_profiles import STOCK_PROFILES
        
        kb_free = dict(entries('', 'meminfo'))['MemFree']
        mb_free = str(round(float(kb_free.split()[0])/1000, 2))

        try:
            pc_path = os.path.join(self.base_directory, mc.DEFAULT_PATHS['profiles'], 'profile.config')
            mc.has_ownership(self.login, pc_path)
        except (OSError, KeyError):
            profile_editable = False
        else:
            profile_editable = True
        finally:
            st = os.stat(pc_path)
            pc_group = getgrgid(st.st_gid).gr_name

        primary_group = getgrgid(getpwnam(self.login).pw_gid).gr_name
    
        return {
            'uptime': int(proc_uptime()[0]),
            'memfree': mb_free,
            'whoami': self.login,
            'group': primary_group,
            'df': dict(disk_free('/')._asdict()),
            'groups': [i.gr_name for i in getgrall() if self.login in i.gr_mem or self.login == 'root'] + [primary_group],
            'pc_permissions': profile_editable,
            'pc_group': pc_group,
            'git_hash': git_hash(os.path.dirname(os.path.abspath(__file__))),
            'stock_profiles': [i['name'] for i in STOCK_PROFILES],
            'base_directory': self.base_directory,
            }
Example #2
0
    def dashboard(self):

        kb_free = dict(procfs_reader.entries('', 'meminfo'))['MemAvailable']
        gb_free = str(round(float(kb_free.split()[0]) / 1000 / 1000,
                            3)) + ' GB'

        primary_group = getgrgid(getpwnam(self.login).pw_gid).gr_name

        return {
            'uptime':
            int(procfs_reader.proc_uptime()[0]),
            'memfree':
            gb_free,
            'whoami':
            self.login,
            'group':
            primary_group,
            'df':
            dict(
                procfs_reader.disk_free(
                    cherrypy.config['misc.base_directory'])._asdict()),
            'groups': [
                i.gr_name for i in getgrall()
                if self.login in i.gr_mem or self.login == 'root'
            ] + [primary_group],
            'base_directory':
            self.base_directory,
        }
Example #3
0
    def dashboard(self):
        from procfs_reader import entries, proc_uptime, disk_free, git_hash
        from grp import getgrall, getgrnam
        
        kb_free = dict(entries('', 'meminfo'))['MemFree']
        mb_free = str(round(float(kb_free.split()[0])/1000, 2))

        try:
            mc.has_ownership(self.login, os.path.join(self.base_directory, mc.DEFAULT_PATHS['profiles'], 'profile.config'))
        except (OSError, KeyError):
            profile_editable = False
        else:
            profile_editable = True
    
        return dumps({
            'uptime': str(proc_uptime()[0]),
            'memfree': mb_free,
            'whoami': self.login,
            'group': getgrnam(self.login).gr_name,
            'df': dict(disk_free('/')._asdict()),
            'groups': [i.gr_name for i in getgrall()
                       if self.login in i.gr_mem or \
                          self.login in [i.gr_name, 'root']],
            'pc_permissions': profile_editable,
            'git_hash': git_hash(os.path.dirname(os.path.abspath(__file__)))
            })
Example #4
0
    def dashboard(self):
        from procfs_reader import entries, proc_uptime, disk_free, git_hash
        from grp import getgrall, getgrgid
        from pwd import getpwnam
        from stock_profiles import STOCK_PROFILES
        
        kb_free = dict(entries('', 'meminfo'))['MemFree']
        mb_free = str(round(float(kb_free.split()[0])/1000, 2))

        try:
            pc_path = os.path.join(self.base_directory, mc.DEFAULT_PATHS['profiles'], 'profile.config')
            mc.has_ownership(self.login, pc_path)
        except (OSError, KeyError):
            profile_editable = False
        else:
            profile_editable = True
        finally:
            st = os.stat(pc_path)
            pc_group = getgrgid(st.st_gid).gr_name

        primary_group = getgrgid(getpwnam(self.login).pw_gid).gr_name
    
        return {
            'uptime': int(proc_uptime()[0]),
            'memfree': mb_free,
            'whoami': self.login,
            'group': primary_group,
            'df': dict(disk_free(cherrypy.config['misc.base_directory'])._asdict()),
            'groups': [i.gr_name for i in getgrall() if self.login in i.gr_mem or self.login == 'root'] + [primary_group],
            'pc_permissions': profile_editable,
            'pc_group': pc_group,
            'git_hash': git_hash(os.path.dirname(os.path.abspath(__file__))),
            'stock_profiles': [i['name'] for i in STOCK_PROFILES],
            'base_directory': self.base_directory,
            }
Example #5
0
    def dashboard(self):
        from procfs_reader import entries, proc_uptime, disk_free

        kb_free = dict(entries('', 'meminfo'))['MemFree']
        mb_free = str(round(float(kb_free.split()[0]) / 1000, 2))

        return dumps({
            'uptime': str(proc_uptime()[0]),
            'memfree': mb_free,
            'whoami': cherrypy.session['_cp_username'],
            'df': dict(disk_free('/')._asdict())
        })