Thursday, April 12, 2012

Prepare for code review!

Thats what I've been doing since I got home at like 3pm.  I went through all of my code, which is the majority in the project.  Since I own the majority, I felt the most pressured to do well tomorrow.  I'm usually proud of the quality of my code, but since I didn't know python well from the start I have some concern that something will be found.  For the most part I expect it to be, "oh you could have named this better".  If that is the worst of my fears, then I think I'll be fine.  Most of what I did today was commenting with the sphinx scheme, which is very close to javadoc.  I did the usual if its not private comment it scheme.  About 90% of my code is in private methods, since most of it is gui boilerplate.  So for the "private" methods, I prefixed them with "_" so I know.  This seems to be the standard in python.

The biggest area of concern for me was the ScanEventEditor.  It is probably the largest single module with about 850 lines of code.  Humongous, I know...  Anyways, my problem with that is python likes to have everything in a single module.  That combined with the small scope of the project I initially decided to keep the controller logic for the editor in the same file as the view stuff.  Terrible.  Well, think about it this way - If I was to make it more MVC modular, I'd put the controller logic in a different class than the view logic.  In python's way of doing things, this would mean I'd have 2 classes in the same module (file).  What would that really get me?  I'd still have to deal with it all in the same file.  The only difference would be at some point in the code I'd add a line "def class <name>".  Thats pretty much it.  What I did do to mitigate any negative feedback about this part is I organized the file layout better.  All the controller code is in the same place, labeled with what parts it controls.  All of the gui creation stuff is in a different part labeled as well.  This way it is almost identical to being in different classes, except I don't have to add inter class communications between them.  Win Win.

The last person I'd like to be tomorrow is Alfonso.  Maybe at some point ackley will get bored looking at gui boilerplate, and ask to see some of Alfonso's code.  Haha!  Good luck trying to find some.

I always think my code could be better.  We'll find out tomorrow if I'm the only one.

Wednesday, April 11, 2012

Finally

After being sick and having my computers crap out, I've gotten my laptop back up and running with the newest version of Ubuntu.  It took me a few hours to configure everything again for python devel, but now I'm in a better position before.  Finally being able to program in this environment and feeling better I went right back to programming.  I've completed 4/6 tasks (not including code cleanup) and I'm certain the last 2 won't take long.

One of the tasks I did today was regarding the Launchpad's looks.  The main argument was that Chris wanted a simpler version that didn't use my terrible microsoft paint graphis, and I wanted something more than just a few buttons.  Well, the deciding argument was won by Chris when we all agreed that neither of us are artistic, so we might as well just stick to what we can do, basic buttons.  Now the window is much smaller for the launchpad, and resizes to fit the other elements.  There are 4 buttons, edit/new/reports and daemon controls.  These are all tightly packed in the 150 x 150 window.

One of the things I worked on that I was not able to get working was the problem that if you resize the window below a certain point, the frames inside stop getting smaller.  This is expected, but you couldn't see the chopped off parts.  The big problem with this is you can't add scrollbars to frames in this gui library.  You can however add them to a "canvas", which at the time this first came up I didn't really understand.  My first approach was to just make a canvas, and put it between the window and the main frame.  Then add the scrollbars to that.  Running this everything showed up fine, but the scrollbars didn't act like anything was there.  I fiddled and googled around and found that canvas's don't init like the other widgets, and you have to call a update_idletasks method on the parent window in order for the sizing to work right.  This fixed it to the point to where the scrollbars knew what size things were, and how much scrolling could be done, but no scrolling actually happened when you moved them.  After searching some more, I didn't find anything that helped but it dawned on me that maybe the canvas was scrolling correctly, but the fact that the contents are all in Frames is the problem.  Since Frames don't scroll, then putting Frames into a canvas won't make them scroll.  I guess the whole deal is off then.  Maybe I can limit how small the window can be made?  That seems to be the only other valid option.

Tuesday, April 10, 2012

blaaaarggggg

is a sufficient term to describe how I've been feeling this week.  I recently went to Florida to visit family.  I didn't sleep the night before the flight in hopes of sleeping during the flight.  That didn't happen.  Then I had poor sleep both nights I was there, and my first night back here I woke up a few times to tango with the toilet.  I'm feeling better today, I still have a lingering cough.  The physical toll it took on my body is more than I excpected though.  I went to work/school for the first time this week, and after walking from the various parking lots to where I needed to go, I spent at least 10 minutes catching my breath.  After getting home in the afternoon, I took a nap.  I then had lunch, and took another nap.  I pulled myself out of bed finally a few hours later to get some homework done.  For the project, other than code cleanup there are a few improvements I've been tasked with.  All of them are pretty small, and I've gotten a few done today.  I fixed the padding in a tab, and redid how I set up the variables and frames for that tab as well.  This also goes with the code cleanliness.

I'm not really worried about the code review.  My code is pretty straight and simple, it pretty much just makes gui widgets.  The names are probably fine, but I'll look over that.  Other than that, there is no public, static, or final modifiers so stylistic things like that aren't going to be considered.  At most it will be the basics of programming:  naming, short succinct methods, modularity, and documentation.  I always incorporate these elements to what I do, except for documentation in this case.  Since I was new to python, I didn't know the standards of commenting (JavaDocs in Java for example) so I didn't do much commenting in the begginning.  Most of my methods are "private" but I guess I should explicitly say so.  A good amount of the "public" ones I have docs for, but I need to go back and make sure they are high quality.

Wednesday, April 4, 2012

Computer Problems Continued

Nothing has yet to improve relative to the situation of my computers.  I'm currently in the process of a full re-install of my laptop, and my desktop still misbehaves.  Luckily, most of the gui has been finished and all that really remains is making it look good.  I still haven't gotten much feedback about this, but the feature freeze is this week and we have all of next week to make it look better.  I sure hope my desktop starts working as it should, and I can get my laptop back up and running.  Otherwise I'm going to be SOL on the remainder of this project.

Tuesday, April 3, 2012

Computer Problems

So I've been re-installing Ubuntu on my laptop for the past couple of weeks since it had an intermittent hard-drive-likes-to-go-into-read-only-mode-every-once-and-a-while problem.  This just happen to occur during a system update, so as you could probably tell it won't boot anymore.  So I just decided to update the OS to a newer Ubuntu version and fix this in the process.  The first install worked fine and all my stuff was still there, but nothing would run.  It would just say that it couldn't run any of the binary files.  I then realized I had accidentally gotten the 32 bit version where as the previous was 64.  No problem, I went and downloaded the correct version and after installing that one it now has Kernel Panics.  I always thought those were such a silly thing.  I could just imagine the Kernel just sitting there with its knees shaking having a nervous breakdown.  Doesn't seem as bad as what it really means.  I'm trying to re-install it to see if it somehow fixes it.

In the meantime, I've switched developing to my desktop which was for gaming only before.  Sadly, it is a Windows machine, so most third party things don't exist.  For the gui, there wasn't anything I needed other than python itself so this wasn't a problem.  Now though, to integrate the Daemon controls to the launchpad I need to install the third party daemon library.  I got the easy_install program that installs python packages, and ran "easy_install daemon".  Eclipse still didn't recognize the package, so I checked to see if it was in my PYTHONPATH variable.  Turns out that var didn't exist.  So in order to create it I had to add a new system variable.  I didn't remember the location of the python home on the file system, so I decided to open up the windows explorer and find out.  I open it up.... nothing shows up in the screen.  I then start to hear some funny noises repeat from my computer.  A few moments later the application crashes and the start menu and all that disappears.  After a few moments all that comes back though.  Great, now this computer is having problems as well.  Good thing all the code and stuff is on SVN.

This has spurred new energy into the restore my laptop project.  It is currently installing again and hopefully should be up tonight.  Good thing most of the heavy lifting in the project is done.  If all goes to hell I can still do stuff on the C.S. machines, but I don't have the ability to install these third party applications there in a timely fashion.  Lets hope it doesn't come to that.

EDIT:

Despite this, I've still managed to accomplish 2 of the features that Ackley suggested:

* The save menu item is disabled when there are no changes to save

* Navigation options allow you to go back and forth from the launchpad.

On the last item, I'm really happy that I've had experience with making Guis of this style before.  In order to make this happen, all I had to do was add a 3 line method to the controller.  The add and remove functions for all of the windows were already implemented, I just had to make it go back as well.  I could see how not building the gui in such a modular way would make things like this nontrivial.  My gui's may not be pretty, but they sure as hell work right.

Thursday, March 29, 2012

Night before Gui Demo

I've dubbed it the Gui demo, because most of the requested items are Gui related.  There are background things that need to be implemented for the Gui stuff to work, and that is what I'm currently waiting on.  Unless I get feedback from my group members, I'm pretty much done with my part.  I'm at the point now with python/Tkinter that adding or changing things goes by really quickyl, due to my knowledge of how it all works and the methods I used to set up things before.  I have only programmed for 2 hours so far today, and I finished the last half of the items I needed for the demo.  I do have an idea on how to improve the Launchpad though, so I'll probably go and do that real quick.  Today I added these enhancements:

  • Completed change notification elements
  • Title bar tells you what file you're working with
  • Reporting manager lets you switch to other reports
  • Improved the New menu command
  • Fixed the layout of the Scheduling tab.

That's it so far.  I'm waiting on method to be implemented that I've created hooks for in my code, so all I'll have to do is call their stuff.

EDIT:

I did what I wanted to do with the launchpad.  It is the rest of the team's fault for letting me design it.  :)

The gui's scheme is gray, black, and white.
 I've asked them a few times for feedback on how to make the gui look better, but I didn't get any.  So I'm just going to do what I want.

For evidence reasons, this is the commit log of the past week:

Commit log of the past week

Wednesday, March 28, 2012

Gui Enhancement

Well the big ticked item for this weeks demo is just Gui enhancements.  It is best summed by this email sent to the group about what we should be doing:

Chris: Report Framework, Scheduler Check/reload, Daemon start/stop/restart, slides for Friday's presentation.

Daniel: Email Item Report selection

BrianK: GUI launchpad, Reporting pane, GUI Polish, Change Detection and Save option, daysBack slider 1-10 + inf, gui option to start/stop/restart daemon.
Reporting window needs (Ad-Hoc Reporting):
Browse button for .nessus file
List box with available report list
Text box for description
Text box for example output
Save-To box/browse button to choose where the report will be saved

BrianD: setuptools/distutils

Alfonso: setuptools/distutils

 I guess I know what I'm doing for the rest of the week.  I started yesterday, but I did the most of it today.  All I really have left is Gui Polish, and the rest of the Reporting Pane.  The Reporting pane will allow you to pick already created reports and push it through a reporting module to process it and save the output.  This way you can do the last half of what the Daemon does without setting up a ScanEvent.  The other things, including Save, Change Detection, Scans To Keep slider (1-10+inf), and the gui options to start/stop the Daemon were really simple and I did almost all of them in an hour.

As for GUI Polish, I'm pretty much screwed.  I'm not good at making GUI's look good, just making good GUIs.  I'll have to look to feedback from the rest of the group for that one.  As far as functionality goes I've added scrollbars and resizing stuff all around, but the GUI itself isn't aesthetically pleasing.  I don't really think there should be much done other than redoing the layout of the Scheduling tab, which is just a bunch of stuff thrown in without any concern whatsoever for looks.  The other tabs are pretty simple and well laid out.  Other than that all I can think of is some padding and changing of colors/borders.  All of these are pretty low on my list of things to do right now.

This awesome coding session brought to you by the awesome song:

http://www.youtube.com/watch?v=hmf34m42JyI

Heads up, this is best listened to loudly.