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

Adding graph_csv.py script #5

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

Guilhermeslucas
Copy link
Contributor

This is very simple script that runs both powergraph.py and csv_creator.py at the same time, making csv files with the latest measures.

@Guilhermeslucas
Copy link
Contributor Author

Just added some more modifications, fixing the problem of no feedback about measuring while storing data on db. Fixing #4 .

graph_csv.py Outdated

INTERVAL = 10

#function used to build the ipmi and csv commands
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functions comments are located between """comment""
def func()
"""my comment"""

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@@ -18,10 +18,20 @@ python2.7 powergraph.py --host="server address" --port="server port" --user="all
```
You can use the optional parameter ```--store``` in order to save
the infos as json on tinydb. Without this parameter, the script will
print on the terminal.
print on the terminal. Besides, you can use ```--feedback``` with store
in order to see the measures status.

Run ```csvcreator.py``` like this:

```
python2.7 csvcreator.py --jsonfile="generated_json_name"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove python 2.7 from the command specification. Given we added it at the top of file. In addition, ensure you chmod +x you Python script before pushing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

graph_csv.py Outdated

return ipmi_command,csv_command

#function to get the arguments from the user
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functions comments are located between """comment""
def func()
"""my comment"""

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

graph_csv.py Outdated
def build_commands(args):
year = time.strftime("%Y")
month = int(time.strftime("%m"))
# DO NOT FORGET TO CHANGE THIS AFTER TESTING
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??? what should you have done here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

graph_csv.py Outdated
day = int(time.strftime("%d")) + 1
date=str(year)+str(month)+str(day)

csv_command = 'python2.7 csvcreator.py --name=last --date='+date+' --jsonfile='
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can also remove python2.7

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As some people use python as an alias for python3, I think that's not a good idea.

graph_csv.py Outdated
help='jsonfile to be converted as csv')
return parser.parse_args()

#function to run the collection of data
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functions comments are located between """comment""
def func()
"""my comment"""

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

graph_csv.py Outdated
def run_collector(command):
os.system(command)

#function to run the csv generator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functions comments are located between """comment""
def func()
"""my comment"""

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

graph_csv.py Outdated
#function to run the csv generator
def run_csv(command):
while 1:
time.sleep(300)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this value be defined by user?

Copy link
Contributor Author

@Guilhermeslucas Guilhermeslucas May 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea. Just did it!

graph_csv.py Outdated
while 1:
time.sleep(300)
os.system(command)
os.system("tail -n 300 last.csv > aux.csv")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we verify for the file availability?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's necessary? Line 85 is in charge of creating it.

@@ -25,7 +25,7 @@
NREAD = 10
INFINITY = False
STORE = False

FEEDBACK = False
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to split the patch in two: one for the run-all-patch and another for this one. Also, ensure you run pylint on all files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. but I didn't undestand waht you mean.

@rpsene
Copy link

rpsene commented May 25, 2017

It is failing when you set empty input. We must identify any missing argument and raise a notification.

09:38:15 | Thu May 25
~/Documents/SDK/Source/tmp/powergraph
rpsene@rpsene : master ./graph_csv.py
Traceback (most recent call last):
File "./graph_csv.py", line 106, in
ipmi_command, csv_command = build_commands(args)
File "./graph_csv.py", line 33, in build_commands
csv_command = csv_command + args.jsonfile
TypeError: cannot concatenate 'str' and 'NoneType' objects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants