From c6a1cfd061988b51bcca2a50cf99040f1e3f347f Mon Sep 17 00:00:00 2001 From: epage Date: Sat, 12 Jul 2008 17:53:02 +0000 Subject: [PATCH] Adding a makefile git-svn-id: file:///svnroot/gc-dialer/trunk@89 c39d3808-3fe2-4d86-a59f-b7f623ee9f21 --- Makefile | 83 +++++++++++++ TODO | 5 - build_script.sh | 21 +--- gc_dialer/gc_dialer.py | 32 ++++- support/pylint.rc | 305 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 424 insertions(+), 22 deletions(-) create mode 100644 Makefile create mode 100644 gc_dialer/__init__.py create mode 100644 support/pylint.rc diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..39c3ca9 --- /dev/null +++ b/Makefile @@ -0,0 +1,83 @@ +PROJECT_NAME=gc_dialer +SOURCE_PATH=./gc_dialer +SOURCE=$(SOURCE_PATH)/gc_dialer.py $(SOURCE_PATH)/gcbackend.py $(SOURCE_PATH)/browser_emu.py +OBJ=$(SOURCE:.py=.pyc) +TEST_PATH=./tests +TAG_FILE=~/.ctags/$(PROJECT_NAME).tags + +PLATFORM=desktop +ifeq ($(PLATFORM),os2007) + LEGACY_GLADE=1 +else + LEGACY_GLADE=0 +endif +PACKAGE_PATH=./pkg-$(PLATFORM) +BUILD_PATH=./build-$(PLATFORM) +BUILD_BIN=$(BUILD_PATH)/gc_dialer.py + +UNIT_TEST=nosetests -w $(TEST_PATH) +STYLE_TEST=../../Python/tools/pep8.py --ignore=W191 +LINT=pylint --rcfile=./support/pylint.rc +COVERAGE_TEST=figleaf +PROFILER=pyprofiler +CTAGS=ctags-exuberant + +.PHONY: all test lint tags build package clean + +all: test tags package + +test: $(SOURCE) + cd $(SOURCE_PATH) ; ./gc_dialer.py -t + +lint: $(SOURCE_PATH) + $(foreach file, $(SOURCE_PATH), $(LINT) $(file) ; ) + +tags: $(TAG_FILE) + +build: $(BUILD_BIN) + mkdir -p $(BUILD_PATH) + + cp $(SOURCE_PATH)/gc_dialer_256.png $(BUILD_PATH) + cp $(SOURCE_PATH)/gc_dialer_64.png $(BUILD_PATH) + cp $(SOURCE_PATH)/gc_dialer_26.png $(BUILD_PATH) + + cp $(SOURCE_PATH)/gc_dialer.desktop $(BUILD_PATH) + + cp $(SOURCE_PATH)/gc_dialer.glade $(BUILD_PATH) + +package: build + mkdir -p $(PACKAGE_PATH)/usr/share/icons/hicolor/scalable/hildon + mkdir -p $(PACKAGE_PATH)/usr/share/icons/hicolor/26x26/hildon + mkdir -p $(PACKAGE_PATH)/usr/share/icons/hicolor/64x64/hildon + mkdir -p $(PACKAGE_PATH)/usr/share/applications/hildon + mkdir -p $(PACKAGE_PATH)/usr/local/lib + mkdir -p $(PACKAGE_PATH)/usr/local/bin + + cp $(BUILD_PATH)/gc_dialer_256.png $(PACKAGE_PATH)/usr/share/icons/hicolor/scalable/hildon/gc_dialer.png + cp $(BUILD_PATH)/gc_dialer_64.png $(PACKAGE_PATH)/usr/share/icons/hicolor/64x64/hildon/gc_dialer.png + cp $(BUILD_PATH)/gc_dialer_26.png $(PACKAGE_PATH)/usr/share/icons/hicolor/26x26/hildon/gc_dialer.png + + cp $(BUILD_PATH)/gc_dialer.desktop $(PACKAGE_PATH)/usr/share/applications/hildon + + cp $(BUILD_PATH)/gc_dialer.glade $(PACKAGE_PATH)/usr/local/lib + + cp $(BUILD_BIN) $(PACKAGE_PATH)/usr/local/bin + +clean: + rm -Rf $(PACKAGE_PATH) $(BUILD_PATH) + rm -Rf $(OBJ) + +$(BUILD_BIN): $(SOURCE) + mkdir -p $(dir $(BUILD_BIN)) + + #Construct the program by cat-ing all the python files together + echo "#!/usr/bin/python2.5" > $(BUILD_BIN) + #echo "from __future__ import with_statement" >> $(PACKAGE_PATH)/usr/local/bin/gc_dialer.py + cat gc_dialer/gc_dialer.py gc_dialer/gcbackend.py gc_dialer/browser_emu.py | grep -e '^import ' | sort -u >> $(BUILD_BIN) + cat gc_dialer/browser_emu.py gc_dialer/gcbackend.py gc_dialer/gc_dialer.py | grep -v 'browser_emu' | grep -v 'gcbackend' | grep -v "#!" >> $(BUILD_BIN) + chmod 755 $(BUILD_BIN) + +$(TAG_FILE): $(SOURCE) + mkdir -p $(dir $(TAG_FILE)) + $(CTAGS) -o $(TAG_FILE) $(SOURCE) + diff --git a/TODO b/TODO index 16a1d69..08744d0 100644 --- a/TODO +++ b/TODO @@ -11,9 +11,6 @@ User Contacts Maemo GPE -Clip board - Implemented, just need something in the GUI to use it - Internet Connection Look into being a bit more advanced, beyond just enabling/disabling the GUI Possible Approach: @@ -26,8 +23,6 @@ Keep callbacks to a minimum amount of blocking I/O Re-examine all use of add_idle I dont think its a thread but idle processing in mainloop, so it could block for long execution -Implement cache clearing on gcbackend.py - Notes ================= General Python/Maemo stuff diff --git a/build_script.sh b/build_script.sh index 122b413..6fe68fd 100755 --- a/build_script.sh +++ b/build_script.sh @@ -30,20 +30,17 @@ BUILD_BASE=./build-$PLATFORM # browser_emu.py -mkdir -p $BUILD_BASE/usr/share/icons/hicolor/scalable/hildon -mkdir -p $BUILD_BASE/usr/share/icons/hicolor/26x26/hildon -mkdir -p $BUILD_BASE/usr/share/icons/hicolor/64x64/hildon +mkdir -p $BUILD_BASE/usr/share/icons/hicolor/{scalable,26x26,64,64}/hildon mkdir -p $BUILD_BASE/usr/share/applications/hildon -mkdir -p $BUILD_BASE/usr/local/bin -mkdir -p $BUILD_BASE/usr/local/lib +mkdir -p $BUILD_BASE/usr/local/{bin,lib} cp gc_dialer/gc_dialer_256.png $BUILD_BASE/usr/share/icons/hicolor/scalable/hildon/gc_dialer.png -cp gc_dialer/gc_dialer_64.png $BUILD_BASE/usr/share/icons/hicolor/64x64/hildon/gc_dialer.png -cp gc_dialer/gc_dialer_26.png $BUILD_BASE/usr/share/icons/hicolor/26x26/hildon/gc_dialer.png +cp gc_dialer/gc_dialer_64.png $BUILD_BASE/usr/share/icons/hicolor/64x64/hildon/gc_dialer.png +cp gc_dialer/gc_dialer_26.png $BUILD_BASE/usr/share/icons/hicolor/26x26/hildon/gc_dialer.png cp gc_dialer/gc_dialer.desktop $BUILD_BASE/usr/share/applications/hildon -cp gc_dialer/gc_dialer.glade $BUILD_BASE/usr/local/lib +cp gc_dialer/gc_dialer.glade $BUILD_BASE/usr/local/lib #Construct the program by cat-ing all the python files together @@ -61,11 +58,3 @@ if [ "$PLATFORM" != "desktop" ]; then # Compress whitespace for 30% savings, make sure we are a HildonWindow sed -i 's/^[ \t]*//;s/[ \t]*$//;s/GtkWindow/HildonWindow/' $BUILD_BASE/usr/local/lib/gc_dialer.glade fi - -#if [ "$LEGACY_GLADE" = "1" ]; then -# echo " Legacy version of Glade" -# sed -i 's/interface/glade-interface/;s/object/widget/' $BUILD_BASE/usr/local/lib/gc_dialer.xml -# #sed -ri 's/(True<\/property>)/\tab\<\/property\>\1/' $BUILD_BASE/usr/local/lib/gc_dialer.xml -# sed -i 's/get_object/get_widget/;s/connect_signals/signal_autoconnect/' $BUILD_BASE/usr/local/bin/gc_dialer.py -#fi - diff --git a/gc_dialer/__init__.py b/gc_dialer/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gc_dialer/gc_dialer.py b/gc_dialer/gc_dialer.py index 43cf9b1..643fc89 100755 --- a/gc_dialer/gc_dialer.py +++ b/gc_dialer/gc_dialer.py @@ -162,6 +162,7 @@ class Dialpad(object): global hildon self._app = None + self._isFullScreen = False if hildon is not None and isinstance(self._window, gtk.Window): warnings.warn("Hildon installed but glade file not updated to work with hildon", UserWarning, 2) hildon = None @@ -172,6 +173,16 @@ class Dialpad(object): self._widgetTree.get_widget("callbackcombo").get_child().set_property('hildon-input-mode', (1 << 4)) self._widgetTree.get_widget("usernameentry").set_property('hildon-input-mode', 7) self._widgetTree.get_widget("passwordentry").set_property('hildon-input-mode', 7|(1 << 29)) + + gtkMenu = self._widgetTree.get_widget("menubar1") + menu = gtk.Menu() + for child in gtkMenu.get_children(): + child.reparent(menu) + self._window.set_menu(menu) + gtkMenu.destroy() + + self._window.connect("key-press-event", self._on_key_press) + self._window.connect("window-state-event", self._on_window_state_change) else: warnings.warn("No Hildon", UserWarning, 2) @@ -183,7 +194,7 @@ class Dialpad(object): device.set_device_state_callback(self._on_device_state_change, 0) if abook is not None and evobook is not None: abook.init_with_name(Dialpad.__app_name__, self._osso) - self._ebook = evo.open_addressbook("default") + self._ebook = evobook.open_addressbook("default") else: warnings.warn("No abook and No evolution address book support", UserWarning, 2) else: @@ -340,6 +351,25 @@ class Dialpad(object): self._window.set_sensitive(False) self._deviceIsOnline = False + def _on_window_state_change(self, widget, event, *args): + """ + @note Hildon specific + """ + if event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN: + self._isFullScreen = True + else: + self._isFullScreen = False + + def _on_key_press(self, widget, event, *args): + """ + @note Hildon specific + """ + if event.keyval == gtk.keysyms.F6: + if self._isFullScreen: + self._window.unfullscreen() + else: + self._window.fullscreen() + def _on_loginbutton_clicked(self, data=None): self._widgetTree.get_widget("login_dialog").response(gtk.RESPONSE_OK) diff --git a/support/pylint.rc b/support/pylint.rc new file mode 100644 index 0000000..b445dcf --- /dev/null +++ b/support/pylint.rc @@ -0,0 +1,305 @@ +# lint Python modules using external checkers. +# +# This is the main checker controling the other ones and the reports +# generation. It is itself both a raw checker and an astng checker in order +# to: +# * handle message activation / deactivation at the module level +# * handle some basic but necessary stats'data (number of classes, methods...) +# +[MASTER] + +# Specify a configuration file. +#rcfile= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Profiled execution. +profile=no + +# Add to the black list. It should be a base name, not a +# path. You may set this option multiple times. +ignore=CVS + +# Pickle collected data for later comparisons. +persistent=yes + +# Set the cache size for astng objects. +cache-size=500 + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + + +[MESSAGES CONTROL] + +# Enable only checker(s) with the given id(s). This option conflicts with the +# disable-checker option +#enable-checker= + +# Enable all checker(s) except those with the given id(s). This option +# conflicts with the enable-checker option +#disable-checker= + +# Enable all messages in the listed categories. +#enable-msg-cat= + +# Disable all messages in the listed categories. +#disable-msg-cat= + +# Enable the message(s) with the given id(s). +#enable-msg= + +# Disable the message(s) with the given id(s). +#disable-msg= + + +[REPORTS] + +# set the output format. Available formats are text, parseable, colorized, msvs +# (visual studio) and html +output-format=text + +# Include message's id in output +include-ids=no + +# Put messages in a separate file for each module / package specified on the +# command line instead of printing them on stdout. Reports (if any) will be +# written in a file name "pylint_global.[txt|html]". +files-output=no + +# Tells wether to display a full report or only the messages +reports=yes + +# Python expression which should return a note less than 10 (10 is the highest +# note).You have access to the variables errors warning, statement which +# respectivly contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (R0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Add a comment according to your evaluation note. This is used by the global +# evaluation report (R0004). +comment=no + +# Enable the report(s) with the given id(s). +#enable-report= + +# Disable the report(s) with the given id(s). +#disable-report= + + +# checks for +# * unused variables / imports +# * undefined variables +# * redefinition of variable from builtins or from an outer scope +# * use of variable before assigment +# +[VARIABLES] + +# Tells wether we should check for unused import in __init__ files. +init-import=no + +# A regular expression matching names used for dummy variables (i.e. not used). +dummy-variables-rgx=_|dummy + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= + + +# checks for : +# * doc strings +# * modules / classes / functions / methods / arguments / variables name +# * number of arguments, local variables, branchs, returns and statements in +# functions, methods +# * required module attributes +# * dangerous default values as arguments +# * redefinition of function / method / class +# * uses of the global statement +# +[BASIC] + +# Required attributes for module, separated by a comma +required-attributes= + +# Regular expression which should only match functions or classes name which do +# not require a docstring +no-docstring-rgx=__.*__ + +# Regular expression which should only match correct module names +module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ + +# Regular expression which should only match correct module level names +const-rgx=(([A-Z_][A-Z1-9_]*)|(__.*__))$ + +# Regular expression which should only match correct class names +class-rgx=[A-Z_][a-zA-Z0-9]+$ + +# Regular expression which should only match correct function names +function-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct method names +method-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct instance attribute names +attr-rgx=[a-z_][a-zA-Z0-9_]{2,30}$ + +# Regular expression which should only match correct argument names +argument-rgx=[a-z_][a-zA-Z0-9_]{2,30}$ + +# Regular expression which should only match correct variable names +variable-rgx=[a-z_][a-zA-Z0-9_]{2,30}$ + +# Regular expression which should only match correct list comprehension / +# generator expression variable names +inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ + +# Good variable names which should always be accepted, separated by a comma +good-names=i,j,k,ex,Run,_ + +# Bad variable names which should always be refused, separated by a comma +bad-names=foo,bar,baz,toto,tutu,tata + +# List of builtins function names that should not be used, separated by a comma +bad-functions=map,filter,apply,input + + +# try to find bugs in the code using type inference +# +[TYPECHECK] + +# Tells wether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# When zope mode is activated, consider the acquired-members option to ignore +# access to some undefined attributes. +zope=no + +# List of members which are usually get through zope's acquisition mecanism and +# so shouldn't trigger E0201 when accessed (need zope=yes to be considered). +acquired-members=REQUEST,acl_users,aq_parent + + +# checks for sign of poor/misdesign: +# * number of methods, attributes, local variables... +# * size, complexity of functions, methods +# +[DESIGN] + +# Maximum number of arguments for function / method +max-args=5 + +# Maximum number of locals for function / method body +max-locals=15 + +# Maximum number of return / yield for function / method body +max-returns=6 + +# Maximum number of branch for function / method body +max-branchs=12 + +# Maximum number of statements in function / method body +max-statements=50 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + + +# checks for : +# * methods without self as first argument +# * overridden methods signature +# * access only to existant members via self +# * attributes not defined in the __init__ method +# * supported interfaces implementation +# * unreachable code +# +[CLASSES] + +# List of interface methods to ignore, separated by a comma. This is used for +# instance to not check methods defines in Zope's Interface base class. +ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__,__new__,setUp + + +# checks for +# * external modules dependencies +# * relative / wildcard imports +# * cyclic imports +# * uses of deprecated modules +# +[IMPORTS] + +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=regsub,string,TERMIOS,Bastion,rexec + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report R0402 must not be disabled) +import-graph= + +# Create a graph of external dependencies in the given file (report R0402 must +# not be disabled) +ext-import-graph= + +# Create a graph of internal dependencies in the given file (report R0402 must +# not be disabled) +int-import-graph= + + +# checks for similarities and duplicated code. This computation may be +# memory / CPU intensive, so you should disable it if you experiments some +# problems. +# +[SIMILARITIES] + +# Minimum lines number of a similarity. +min-similarity-lines=4 + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + + +# checks for: +# * warning notes in the code like FIXME, XXX +# * PEP 263: source code with non ascii character but no encoding declaration +# +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME,XXX,TODO + + +# checks for : +# * unauthorized constructions +# * strict indentation +# * line length +# * use of <> instead of != +# +[FORMAT] + +# Maximum number of characters on a single line. +max-line-length=80 + +# Maximum number of lines in a module +max-module-lines=1000 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string='\t' -- 1.7.9.5