Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folding #181

Merged
merged 3 commits into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed(folding): return floats instead of rounding + fixed -fff ...
  • Loading branch information
strizhechenko committed Dec 19, 2017
commit 56d6035a996dbcc1a8b0f9257a9d3c568dfdb6e4
13 changes: 3 additions & 10 deletions netutils_linux_hardware/assessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,13 @@ def __init__(self, data):
self.assess()

def fold(self, data, level):
""" Схлапывает значения в дикте до среднего арифметического """
if not data:
return 1
if self.args.folding < level:
return data
if self.args.folding >= FOLDING_SERVER:
print(data)
s = sum(data.values())
print('1231312443')
k = len(data.keys())
print('1231312666')
r = s / k
result = r
print('1231312', r)
return result
result = sum(data.values()) / len(data.keys())
return result if level < FOLDING_SERVER else {'server': result}

def __str__(self):
return yaml.dump(self.info, default_flow_style=False).strip()
Expand Down
21 changes: 7 additions & 14 deletions utils/server-info-rate
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,13 @@ from netutils_linux_hardware.assessor import Assessor
from netutils_linux_hardware.reader import Reader


def get_datadir():
default_data_directory = 'tests/autotune_network.tests/2xE5-2640.i350_and_82599ES.l2_mixed.masterconf'
if os.path.isfile(os.path.join(os.getcwd(), 'lspci')):
return os.getcwd()
return os.environ.get('DATADIR', default_data_directory)


if __name__ == '__main__':
print('kek')
directory = get_datadir()
print('kek2')
def main():
cwd = os.getcwd()
directory = cwd if os.path.isfile(os.path.join(cwd, 'lspci')) else os.getenv('DATADIR')
reader = Reader(directory)
print('kek4')
assessor = Assessor(reader.info)
print('kek5')
print_(assessor)
print('kek3')


if __name__ == '__main__':
main()