Skip to content

Commit

Permalink
Initializing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sulstice committed Dec 4, 2020
1 parent 9ec5eb3 commit adcf115
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 0 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include README.md requirements.in requirements.txt
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
LogReader: A logreader function to read your files!
===================================================

![Python](https://img.shields.io/badge/python-3.6-blue.svg)
[![PEP8](https://img.shields.io/badge/code%20style-pep8-orange.svg)](https://www.python.org/dev/peps/pep-0008/)


Announcements
=============

- Work has began! Dec 4th

Installation
============

LogReader is going to be distribute via PyPi and as the content store grows we can expand it to other pieces of software
making it accessible to all regardless of what you use. Alternatively, you could have a glance at the source code and copy/paste
it yourself.


Structure of LogReader
=======================

Currently, the main subpackages are:

- **logreader**: logreader main class.


Genesis
=======

LogReader was created because I noticed I was using the same variable across multiple scripts and figure it would be useful
for folk to have.

- Lead Developer [Suliman sharif](http://sulstice.github.io/)


* * * * *

External links
==============


10 changes: 10 additions & 0 deletions logreader/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#!/usr/bin/env python3
#
# Intialization of the package
#
# ----------------------------

from logreader.logreader import LogReader

name='LogReader'
99 changes: 99 additions & 0 deletions logreader/logreader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Authentication to Apollo

class LogReader(object):

__version__ = '0.0.1'

def __init__(self, target_directory, target_log):

'''
Initialize to find the target logs and readers
'''
self.user, self.hostname = self._read_authentication()

self.target_directory = target_directory
self.target_log = target_log
self.timings = {}
self._read_loggers()


def _read_authentication(self):


"""
Read in the authentication file into apollo
"""

from ruamel.yaml import YAML
yaml = YAML()

import os

cwd = os.path.dirname(os.path.abspath(__file__))

with open(os.path.join(cwd, 'auth_apollo.yml')) as auth_file:

try:
auth_info = yaml.load(auth_file)
except Exception as exc:
print('Problems handling in reading in the authentication file')


user = auth_info['username']
hostname = auth_info['host']

return user, hostname

def _read_loggers(self):

"""
Read the log files for GROMACS software to get step values
"""

from fabric.connection import Connection

with Connection(self.hostname, self.user) as portal:

# Find the file paths
file_paths_stream = portal.run('find ' + self.target_directory + ' -type f -name "' + self.target_log + '"', hide=True)
file_paths = file_paths_stream.stdout.strip().split('\n')

# Grep the logs
for file_path in file_paths:

stdout_stream = portal.run('tail -n 13 ' + file_path + '', hide=True)
stdout = stdout_stream.stdout.strip().split('\n')[0].split('vol')[0].strip().split(' ')[-1]
self.timings[file_path] = stdout

def generate_table(self):

'''
Generate a stdout of table values
'''

from beautifultable import BeautifulTable

table = BeautifulTable()

table.column_headers = ["--- File Path ---", "Step", "Time (ns)"]

for key, value in self.timings.items():

row = []
row.append(key.replace(self.target_log, ''))
row.append(value)
row.append(float(value) / 500000)

table.append_row(row)

print(table)
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ruamel.yaml==0.16.5
fabric==2.5.0
beautifultable==1.0.0
64 changes: 64 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# package setup
#
# ------------------------------------------------

# imports
# -------
import os

# config
# ------
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup, find_packages

# requirements
# ------------
with open('requirements.txt') as f:
REQUIREMENTS = f.read().strip().split('\n')

if os.path.exists('README.md'):
long_description = open('README.md').read()
else:
long_description = 'LogReader- A quick utility tool for reading log files'

TEST_REQUIREMENTS = [
'pytest',
'pytest-runner'
]

# exec
# ----
setup(
name="logreader",
version="0.0.1",
packages=['logreader'],
license='MIT',
author="Suliman Sharif",
author_email="sharifsuliman1@gmail.com",
url="https://github.com/Shen-Group/LogReader",
install_requires=REQUIREMENTS,
long_description=long_description,
long_description_content_type='text/markdown',
zip_safe=False,
keywords='logreader logs GROMACS',
classifiers=[
'Development Status :: 4 - Beta',
'Natural Language :: English',
'License :: OSI Approved :: MIT License',
'Intended Audience :: Developers',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
test_suite='tests',
tests_require=TEST_REQUIREMENTS,
)
Empty file added tests/__init__.py
Empty file.

0 comments on commit adcf115

Please sign in to comment.