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

[Tools] Added -d (--detailed) paremeter to unfold 'Misc' contents in memap.py table #2845

Merged
merged 5 commits into from
Sep 30, 2016

Conversation

javier-moreno-tridonic-com
Copy link
Contributor

@javier-moreno-tridonic-com javier-moreno-tridonic-com commented Sep 28, 2016

Description

Adds more detail to the Misc contents from memap.py

Status

READY

Migrations

NO

Todos

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 28, 2016

Copy link
Contributor

@theotherjimmy theotherjimmy left a comment

Choose a reason for hiding this comment

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

I like were this is going.

argparse_lowercase_hyphen_type, argparse_uppercase_type

DEBUG = False
DETAILED = False
Copy link
Contributor

@theotherjimmy theotherjimmy Sep 28, 2016

Choose a reason for hiding this comment

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

Global variables should not change, so that if we ever need to run many of these concurrently in the same process, we can. Could we make this an object variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by this? just define it as lowercase?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean: Don't use a global variable for something that changes at runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

args cannot be accessed from inside the path_object_to_module_name so, unless I add another parameter to path_object_to_module_name signature and propagate it all the way up to the main, I don't see how to implement this without a global variable.

Is this what you would like me to implement? Is there an easier solution?

It is like the 5th time or so that I code something in python so I'd appreciate the input :)

Copy link
Contributor

@theotherjimmy theotherjimmy Sep 29, 2016

Choose a reason for hiding this comment

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

You could: remove the @statictmethod decorator from path_object_to_module_name giving you access to self (you would also have to add it as the first parameter). Then you could pass detailed into the constructor, with a default value of False, assigning it to an attirbute of the object, say detailed_names. That's how I would do 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.

Thanks for the input :)

Done

@@ -10,10 +10,11 @@
import argparse
from prettytable import PrettyTable

from tools.utils import argparse_filestring_type, \
Copy link
Contributor

Choose a reason for hiding this comment

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

You cannot correctly drop the tools. from the front of this import. Please undo this change, as it has nothing to do with the feature being implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I didn't drop the tool from the front of the import I get the following error runing memap.py as standalone from the tools folder (python memap.py ...)

Traceback (most recent call last):
File "memap.py", line 13, in
from tools.utils import argparse_filestring_type,
ImportError: No module named tools.utils

Copy link
Contributor

Choose a reason for hiding this comment

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

We'll leave it as it is then.


# Parse/run command
if len(sys.argv) <= 1:
parser.print_help()
sys.exit(1)


args = parser.parse_args()
args, remainder = parser.parse_known_args()
Copy link
Contributor

@theotherjimmy theotherjimmy Sep 28, 2016

Choose a reason for hiding this comment

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

We don't use parse_know_args. Could you undo this change as well? it also seems unrelated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one slipped trough (I was porting my changes from an older version of memap.py

I'll change it right away :)

@mazimkhan
Copy link

retest uvisor

Copy link
Contributor

@theotherjimmy theotherjimmy left a comment

Choose a reason for hiding this comment

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

The change set is getting better. Just a few more things...


# Show Misc unfolded
if args.detailed:
memap.detailed_misc = True
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you pass this into the constructor instead?
e.g.

memap = MemapParser(args.detailed)

@@ -40,7 +41,9 @@ class MemapParser(object):
def __init__(self):
Copy link
Contributor

@theotherjimmy theotherjimmy Sep 30, 2016

Choose a reason for hiding this comment

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

Then also change this to:

def __init__(self, detailed_misc=False)
""" General initialization
"""

self.detailed_misc = detailed_misc


# Parse/run command
if len(sys.argv) <= 1:
parser.print_help()
sys.exit(1)


args = parser.parse_args()
args = parser.parse_args()
Copy link
Contributor

Choose a reason for hiding this comment

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

Spaces added.

@screamerbg
Copy link
Contributor

@javier-moreno-tridonic-com Can you please address the issues @theotherjimmy pointed?

Otherwise looks great!

@screamerbg screamerbg changed the title Added -d (--detailed) paremeter to unfold 'Misc' contents in memap.py table [Tools] Added -d (--detailed) paremeter to unfold 'Misc' contents in memap.py table Sep 30, 2016
@theotherjimmy
Copy link
Contributor

@javier-moreno-tridonic-com I'm going to do the changes myself, so that we can get this into the code base real quick.

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.

6 participants