diff options
author | Siddharth Ravikumar <sravik@bgsu.edu> | 2016-02-29 23:16:11 -0500 |
---|---|---|
committer | Siddharth Ravikumar <sravik@bgsu.edu> | 2016-02-29 23:16:11 -0500 |
commit | 8df4b447a8838983c30b2227293d10ac1ad41b93 (patch) | |
tree | 8877728cabb53360a97a0a790bf7166ae52f402a | |
parent | 2a5e5d1ea482216771013769e4bec0adefd8d69e (diff) |
Drafted Chapter 5.
-rw-r--r-- | report/Makefile | 2 | ||||
-rw-r--r-- | report/appendix/combox-2to3.tex | 12 | ||||
-rw-r--r-- | report/chapters/5-con-f.tex | 56 | ||||
-rw-r--r-- | report/code/combox-2to3.diff | 298 | ||||
-rw-r--r-- | report/combox-report.pdf | bin | 390061 -> 468420 bytes | |||
-rw-r--r-- | report/combox.tex | 9 |
6 files changed, 375 insertions, 2 deletions
diff --git a/report/Makefile b/report/Makefile index 2b1a083..6c8e958 100644 --- a/report/Makefile +++ b/report/Makefile @@ -12,7 +12,7 @@ PDF = combox-report.pdf REPORT_TEX = combox.tex REPORT_AUX = combox.aux -REPORT_INCLUDES = graphs/*.tex chapters/*.tex bib/combox.bib +REPORT_INCLUDES = graphs/*.tex chapters/*.tex bib/combox.bib appendix/*.tex DVI = combox.dvi all: $(PDF) diff --git a/report/appendix/combox-2to3.tex b/report/appendix/combox-2to3.tex new file mode 100644 index 0000000..879eecb --- /dev/null +++ b/report/appendix/combox-2to3.tex @@ -0,0 +1,12 @@ +\chapter{Making combox Python 3 compatible}\label{a-python3c} + +\epigraph{Indeed, when you see new 3.x versions rolling off the line + and no one using them, it’s hard to shake the feeling that Python + might die in this transition. How will we ever make it across the + chasm?}{\textit{Aaron Swartz, March 2012}} + +What follows is the changes that will have to be made to make combox +compatible with Python version 3.x; it was generated by the +\verb+2to3+ program. + +\lstinputlisting[basicstyle=\scriptsize]{code/combox-2to3.diff}
\ No newline at end of file diff --git a/report/chapters/5-con-f.tex b/report/chapters/5-con-f.tex index 2005795..0adb875 100644 --- a/report/chapters/5-con-f.tex +++ b/report/chapters/5-con-f.tex @@ -26,3 +26,59 @@ repository is also mirrored at \url{https://bitbucket.org/bgsucodeloverslab/combox/src} and \url{http://rsiddharth.ninth.su/git/cb.git/}. +There are a lot of things that can be done to improve combox, what +follows is a non-exhaustive list of things to do in the future: + +\begin{itemize} +\item Make combox cognizant about space available on each node + directory. At the moment, combox reads the amount of free space + available on each node directory (file storage provider's directory) + when configuring combox a computer but does not use this information + to reckon the space left in each node directory. +\item Re-think \verb+combox.events+ module. This module was written + with the assumption that combox will be the only one to make changes + to the node directories. This assumption was found to be not true + when manually testing combox with node clients (Google Drive and + Dropbox client that sync files from the respective node directories + to their respective servers); both the Google Drive and the Dropbox + client make modifications to the Google Drive and Dropbox directory + respectively whenever pulling a modified shard from their server to + this computer, this behavior broke combox and major changes were + made to the \verb+combox.events+ module to make it understand the + node client's behavior in the node directory; these changes, + increased the complexity of the classes defined in the + \verb+combox.events+; it would be great to re-think this module in + such a way that it reduces its complexity. +\item Evaluate if more information needs to tracked about each file in + the combox directory; at the moment, combox only keeps track of the + SHA256 hash of each file stored in the combox directory. +\item Support more file storage providers; for this, ideally no code + needs to be written for supporting a new file storage provider, + combox must be tested with the new file storage provider's directory + as a node directory. If the new file storage provider's client (that + sync's the shards their servers) makes non-standard changes to its + directory (like the official Dropbox and Google Drive clients do), + then the \verb+combox.events.NodeDirMonitor+ must be accordingly + updated to make combox cognizant about the file storage provider + client's non-standard behavior. +\item Make unit tests more modular. At the moment, there are some unit + test function that test more than one usecase/facet of a function or + class; for instance, the \verb+test_CDM+ test method part of the the + \verb+tests.events_test.TestEvents+ test class tests the correctness + of the \verb+combox.events.ComboxDirMonitor+ for file creation, + deletion, rename and modification; this method would ideally broken + down into four tests methods. +\item Make combox Python 3 compatible. The \verb+2to3+ program (which + is part of the standard Python library since Python version 2.6) and + the \verb+six+ library can be used to achieve this. See Appendix + \ref{a-python3c} for more information on this. +\item Support Microsoft Windows. The way to make combox compatible + with Windows will be to run unit tests on Windows, the failing tests + might give pointers to what parts of combox needs to be changed in + order for it to be compatible with Windows. Individuals interested + in making combox compatible with Windows might find + \url{https://ricketyspace.net/combox/setup/#windows} this useful; it + contains information about setting up the development environment + for combox on Windows. +\end{itemize} + diff --git a/report/code/combox-2to3.diff b/report/code/combox-2to3.diff new file mode 100644 index 0000000..1004037 --- /dev/null +++ b/report/code/combox-2to3.diff @@ -0,0 +1,298 @@ +--- combox/_version.py (original) ++++ combox/_version.py (refactored) +@@ -18,8 +18,8 @@ + # along with Combox (see COPYING). If not, see + # <http://www.gnu.org/licenses/>. + +-__version__ = u"0.2" +-__release__ = u"2" ++__version__ = "0.2" ++__release__ = "2" + + + def get_version(): +--- combox/config.py (original) ++++ combox/config.py (refactored) +@@ -84,7 +84,7 @@ + + prompt = "%s: " % (prompt) + +- return raw_input(prompt) ++ return input(prompt) + + + def config_cb(config_dir = path.join(expanduser("~"), '.combox'), +@@ -143,7 +143,7 @@ + + if not path.exists(config_dir): + # Create combox config directory. +- os.mkdir(config_dir, 0700) ++ os.mkdir(config_dir, 0o700) + + if not path.exists(config_info['combox_dir']): + # Create combox directory. +@@ -171,7 +171,7 @@ + """ + nodes = [] + +- for node in config['nodes_info'].itervalues(): ++ for node in config['nodes_info'].values(): + node_path = path.abspath(node['path']) + nodes.append(node_path) + +--- combox/crypto.py (original) ++++ combox/crypto.py (refactored) +@@ -178,7 +178,7 @@ + rel_path = relative_path(fpath, config) + + # no. of shards = no. of nodes. +- SHARDS = len(config['nodes_info'].keys()) ++ SHARDS = len(list(config['nodes_info'].keys())) + + f = path.join(config['combox_dir'], rel_path) + +--- combox/events.py (original) ++++ combox/events.py (refactored) +@@ -135,7 +135,7 @@ + + # Remove information about files that were deleted. + fpath_filter = lambda x: x not in self.silo.nodedicts() +- fpaths = filter(fpath_filter, self.silo.keys()) ++ fpaths = list(filter(fpath_filter, list(self.silo.keys()))) + + for fpath in fpaths: + if not path.exists(fpath): +@@ -336,7 +336,7 @@ + # event; we're tracking this behaviour and ignoring + # the 'file modified' event. + # +- if (self.just_created.has_key(event.src_path) and ++ if (event.src_path in self.just_created and + self.just_created[event.src_path] and + platform.system() == 'Linux'): + self.just_created[event.src_path] = False +@@ -476,7 +476,7 @@ + # deleted. + # Remove information about files that were deleted. + fpath_filter = lambda x: x not in self.silo.nodedicts() +- fpaths = filter(fpath_filter, self.silo.keys()) ++ fpaths = list(filter(fpath_filter, list(self.silo.keys()))) + + for fpath in fpaths: + del_num = 0 +@@ -522,7 +522,7 @@ + else: + files_created[file_cb_path] += 1 + +- for f_cb_path, crt_num in files_created.items(): ++ for f_cb_path, crt_num in list(files_created.items()): + if crt_num == self.num_nodes: + log_i("%s was created remotely. Creating it locally now..." % + f_cb_path) +@@ -663,7 +663,7 @@ + else: + try: + os.renames(src_cb_path, dest_cb_path) +- except OSError, e: ++ except OSError as e: + log_e("Jeez, failed to rename path. %r" % e) + self.silo.node_rem(silo_node_dict, src_cb_path) + +@@ -859,7 +859,7 @@ + # tracking this behaviour and ignoring the 'file modified' + # event. + # +- if (self.just_created.has_key(event.src_path) and ++ if (event.src_path in self.just_created and + self.just_created[event.src_path] and + platform.system() == 'Linux'): + self.just_created[event.src_path] = False +--- combox/file.py (original) ++++ combox/file.py (refactored) +@@ -58,7 +58,7 @@ + + if directory is None: + err_msg = "invalid path %s" % p +- raise ValueError, err_msg ++ raise ValueError(err_msg) + + return p.partition(directory)[2] + +@@ -192,7 +192,7 @@ + """ + try: + os.mkdir(directory) +- except OSError, e: ++ except OSError as e: + log_e("Error when trying to make directory %s" % directory) + + +@@ -227,7 +227,7 @@ + elif path.isdir(fpath): + purge_dir(fpath) + os.rmdir(fpath) +- except OSError, e: ++ except OSError as e: + log_e("Error when trying to remove path %s" % fpath) + + +@@ -253,7 +253,7 @@ + dest_dir_path = path.join(node, dest_rel_path) + try: + os.renames(src_dir_path, dest_dir_path) +- except OSError, e: ++ except OSError as e: + log_e("Error when trying to rename %s -> %s" % (src_dir_path, dest_dir_path)) + + +@@ -284,7 +284,7 @@ + shard = shard_glob[0] + try: + os.remove(shard) +- except OSError, e: ++ except OSError as e: + log_e("Error when trying to remove shard %s" % shard) + + +@@ -325,7 +325,7 @@ + shard_no) + try: + os.renames(src_shard, dest_shard) +- except OSError, e: ++ except OSError as e: + log_e("Error when trying to rename shard %s -> %s" % (src_shard, dest_shard)) + + +--- combox/gui.py (original) ++++ combox/gui.py (refactored) +@@ -20,12 +20,12 @@ + + import os + +-import tkFileDialog ++import tkinter.filedialog + + from os import path + from os.path import expanduser + +-from Tkinter import * ++from tkinter import * + + from combox.config import config_cb + +@@ -165,7 +165,7 @@ + + .. _Formatted string: https://docs.python.org/2/library/stdtypes.html#string-formatting + """ +- print type(args), args ++ print(type(args), args) + self.status_bar.config(text=format % args) + self.status_bar.update_idletasks() + +@@ -284,14 +284,14 @@ + return False + + # validate node paths +- for i in xrange(len(self.node_path_entries)): ++ for i in range(len(self.node_path_entries)): + if not self.node_path_entries[i].get(): + self.status_bar_set("%s %d", "give the path for node", i) + self.node_path_entries[i].focus_set() + return False + + # validate node sizes +- for i in xrange(len(self.node_size_entries)): ++ for i in range(len(self.node_size_entries)): + if not self.node_size_entries[i].get(): + self.status_bar_set("%s %d", "give the size of node", i) + self.node_size_entries[i].focus_set() +@@ -323,13 +323,13 @@ + config_info = [combox_name, combox_dir, '', no_nodes] + + # get info about nodes. +- for i in xrange(len(self.node_path_entries)): ++ for i in range(len(self.node_path_entries)): + config_info.append("node_%d" % i) + config_info.append(self.node_path_entries[i].get()) + config_info.append(self.node_size_entries[i].get()) + + config_info_iter = iter(config_info) +- def_input = lambda(x): next(config_info_iter) ++ def_input = lambda x: next(config_info_iter) + def_pass = lambda: passp + + config_cb(config_dir=self.config_dir, +@@ -367,7 +367,7 @@ + entry.delete(0, 'end') + + # spawn dialog to choose directory. +- dir_path = tkFileDialog.askdirectory() ++ dir_path = tkinter.filedialog.askdirectory() + entry.insert(0, dir_path) + + +@@ -376,7 +376,7 @@ + + """ + +- for i in xrange(len(self.node_path_labels)): ++ for i in range(len(self.node_path_labels)): + self.node_path_labels[i].destroy() + self.node_path_entries[i].destroy() + self.node_size_labels[i].destroy() +@@ -416,7 +416,7 @@ + # information" before; get rid of 'em. + self.clear_node_info_fields() + +- for i in xrange(no_nodes): ++ for i in range(no_nodes): + node_path_str = 'node %d path' % i + node_size_str = 'node %d size (in mega bytes)' % i + +--- combox/silo.py (original) ++++ combox/silo.py (refactored) +@@ -109,7 +109,7 @@ + # instead of PickleDB + self.reload() + with self.lock: +- return self.db.db.keys() ++ return list(self.db.db.keys()) + + + def remove(self, filep): +@@ -128,7 +128,7 @@ + self.reload() + with self.lock: + return self.db.rem(filep) +- except KeyError, e: ++ except KeyError as e: + # means `filep' not present in db. + return False + +@@ -209,7 +209,7 @@ + try: + num = self.db.dget(type_, file_) + num += 1 +- except KeyError, e: ++ except KeyError as e: + # I don't think this is the right way to do this. :| + # + # If we are here it means file_ is not already there, +@@ -252,7 +252,7 @@ + with self.lock: + try: + return self.db.dget(type_, file_) +- except KeyError, e: ++ except KeyError as e: + # file_ info not there under type_ dict. + return None + +@@ -272,7 +272,7 @@ + with self.lock: + try: + return self.db.dpop(type_, file_) +- except KeyError, e: ++ except KeyError as e: + # means file_'s info was already removed. + # do nothing + pass diff --git a/report/combox-report.pdf b/report/combox-report.pdf Binary files differindex adc1ee2..c1b08bb 100644 --- a/report/combox-report.pdf +++ b/report/combox-report.pdf diff --git a/report/combox.tex b/report/combox.tex index 74d695b..d6e4627 100644 --- a/report/combox.tex +++ b/report/combox.tex @@ -2,6 +2,7 @@ \usepackage{hyperref}
\usepackage{epigraph}
+\usepackage{listings}
\usepackage[dvips]{graphicx}
\graphicspath{{images/}}
@@ -355,16 +356,22 @@ %% 3
\include{chapters/3-arch-d}
-
%% 4
\include{chapters/4-testing}
%% 5
\include{chapters/5-con-f}
+%% references
\bibliographystyle{IEEEtran}
\bibliography{bib/combox}
+%% appendix
+\appendix
+
+\include{appendix/combox-2to3}
+
+
\end{document} %---> ---> ---> ---> DO NOT ALTER THIS COMMAND
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|