Created
October 17, 2010 21:04
-
-
Save phillbaker/631291 to your computer and use it in GitHub Desktop.
rapidsms_python2-5.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 787dd8c55a4cee7fdfdbf509e7b3cac109504fe2 Mon Sep 17 00:00:00 2001 | |
From: pbaker <[email protected]> | |
Date: Sun, 3 Oct 2010 23:35:48 -0400 | |
Subject: [PATCH 1/3] *nix-based kludge to workaround absence of ignore_patterns in python 2.5, only appeared in 2.6 | |
--- | |
lib/rapidsms/management/commands/startproject.py | 19 +++++++++++++------ | |
1 files changed, 13 insertions(+), 6 deletions(-) | |
diff --git a/lib/rapidsms/management/commands/startproject.py b/lib/rapidsms/management/commands/startproject.py | |
index b7f066a..358e687 100644 | |
--- a/lib/rapidsms/management/commands/startproject.py | |
+++ b/lib/rapidsms/management/commands/startproject.py | |
@@ -4,18 +4,19 @@ | |
import os | |
import shutil | |
-from django.core.management.base import CommandError, LabelCommand | |
+from django.core.management.base import copy_helper, CommandError, LabelCommand | |
from rapidsms.utils.modules import try_import | |
import rapidsms | |
# this is mostly copy/pasted from django. unfortunately, the copy | |
-# mechanism had to be replaced, since django hard-codes some paths. | |
+# mechanism had to be replaced, since django hard-codes the path | |
+# of the template file. | |
class Command(LabelCommand): | |
- help = "Creates a RapidSMS project in the current directory." | |
- args = "[projectname]" | |
+ help = 'Creates a RapidSMS project in the current directory.' | |
+ args = '[projectname]' | |
label = 'project name' | |
requires_model_validation = False | |
@@ -27,5 +28,11 @@ class Command(LabelCommand): | |
"%r conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name." % | |
project_name) | |
- src_dir = os.path.join(rapidsms.__path__[0], "skeleton", "project") | |
- shutil.copytree(src_dir, project_name, ignore=shutil.ignore_patterns('*.pyc')) | |
+ src_dir = os.path.join(rapidsms.__path__[0], 'skeleton', 'project') | |
+ #use Django's copy_helper, not shutil.copytree | |
+ #shutil.copytree(src_dir, project_name, ignore=shutil.ignore_patterns('*.pyc')) | |
+ #or how about setting django.__path__[0] to rapidsms.__path__[0] and putting rapidsms/skeleton/project in rapidsms/conf/project_template to match django? | |
+ #copy_helper(self.style, 'project', src_dir, project_name) | |
+ shutil.copytree(src_dir, project_name) | |
+ os.system('find ./project_name -name "*.pyc" -delete') | |
+ | |
-- | |
1.7.2.1 | |
From 4182272534cba886644314e76684620793c2f04d Mon Sep 17 00:00:00 2001 | |
From: pbaker <[email protected]> | |
Date: Sun, 3 Oct 2010 23:44:01 -0400 | |
Subject: [PATCH 2/3] didn't escape variable | |
--- | |
lib/rapidsms/management/commands/startproject.py | 2 +- | |
1 files changed, 1 insertions(+), 1 deletions(-) | |
diff --git a/lib/rapidsms/management/commands/startproject.py b/lib/rapidsms/management/commands/startproject.py | |
index 358e687..994dc90 100644 | |
--- a/lib/rapidsms/management/commands/startproject.py | |
+++ b/lib/rapidsms/management/commands/startproject.py | |
@@ -34,5 +34,5 @@ class Command(LabelCommand): | |
#or how about setting django.__path__[0] to rapidsms.__path__[0] and putting rapidsms/skeleton/project in rapidsms/conf/project_template to match django? | |
#copy_helper(self.style, 'project', src_dir, project_name) | |
shutil.copytree(src_dir, project_name) | |
- os.system('find ./project_name -name "*.pyc" -delete') | |
+ os.system('find ./' + project_name + ' -name "*.pyc" -delete') | |
-- | |
1.7.2.1 | |
From b1a5a45ed20d760a7b8a7c4d4d47601a2d8c2a37 Mon Sep 17 00:00:00 2001 | |
From: pbaker <[email protected]> | |
Date: Thu, 14 Oct 2010 11:27:58 -0400 | |
Subject: [PATCH 3/3] changes for py2.5 compatible rapidsms in theme, location app, router and tests | |
--- | |
lib/rapidsms/contrib/locations/app.py | 2 +- | |
lib/rapidsms/contrib/locations/forms.py | 3 ++- | |
lib/rapidsms/contrib/locations/views.py | 6 +++--- | |
lib/rapidsms/forms.py | 2 +- | |
lib/rapidsms/router.py | 2 +- | |
lib/rapidsms/templatetags/tabs_tags.py | 2 +- | |
lib/rapidsms/tests/backend/test_base.py | 6 +++--- | |
7 files changed, 12 insertions(+), 11 deletions(-) | |
diff --git a/lib/rapidsms/contrib/locations/app.py b/lib/rapidsms/contrib/locations/app.py | |
index 11877b1..78a7f07 100644 | |
--- a/lib/rapidsms/contrib/locations/app.py | |
+++ b/lib/rapidsms/contrib/locations/app.py | |
@@ -4,7 +4,7 @@ | |
import re | |
from rapidsms.apps.base import AppBase | |
-from .models import * | |
+from .models import Location | |
class App(AppBase): | |
diff --git a/lib/rapidsms/contrib/locations/forms.py b/lib/rapidsms/contrib/locations/forms.py | |
index 908036e..4ec4dcc 100644 | |
--- a/lib/rapidsms/contrib/locations/forms.py | |
+++ b/lib/rapidsms/contrib/locations/forms.py | |
@@ -6,7 +6,8 @@ from django.utils.translation import ugettext_lazy as _ | |
from django.forms import widgets | |
from django.forms import fields | |
from django import forms | |
-from .models import * | |
+from .models import Point | |
+from .models import Location | |
class PointWidget(widgets.MultiWidget): | |
diff --git a/lib/rapidsms/contrib/locations/views.py b/lib/rapidsms/contrib/locations/views.py | |
index ad07f9a..8d36b37 100644 | |
--- a/lib/rapidsms/contrib/locations/views.py | |
+++ b/lib/rapidsms/contrib/locations/views.py | |
@@ -9,9 +9,9 @@ from django.shortcuts import render_to_response, get_object_or_404 | |
from django.views.decorators.http import require_GET, require_http_methods | |
from rapidsms.utils import web_message | |
from rapidsms.conf import settings | |
-from .forms import * | |
-from .models import * | |
-from .tables import * | |
+from .forms import LocationForm | |
+from .models import Location | |
+from .tables import LocationTable | |
from . import utils | |
diff --git a/lib/rapidsms/forms.py b/lib/rapidsms/forms.py | |
index fe69e8f..273cc3b 100644 | |
--- a/lib/rapidsms/forms.py | |
+++ b/lib/rapidsms/forms.py | |
@@ -3,7 +3,7 @@ | |
from django import forms | |
-from .models import * | |
+from .models import Contact | |
class ContactForm(forms.ModelForm): | |
diff --git a/lib/rapidsms/router.py b/lib/rapidsms/router.py | |
index 9c7e2b1..7cb926e 100644 | |
--- a/lib/rapidsms/router.py | |
+++ b/lib/rapidsms/router.py | |
@@ -177,7 +177,7 @@ class Router(object, LoggerMixin): | |
""" | |
for backend in self.backends.values(): | |
- alive = backend.__thread.is_alive | |
+ alive = backend.__thread.isAlive | |
if not alive(): continue | |
backend.stop() | |
diff --git a/lib/rapidsms/templatetags/tabs_tags.py b/lib/rapidsms/templatetags/tabs_tags.py | |
index f93b8cc..6410de2 100644 | |
--- a/lib/rapidsms/templatetags/tabs_tags.py | |
+++ b/lib/rapidsms/templatetags/tabs_tags.py | |
@@ -51,7 +51,7 @@ class TabsNode(template.Node): | |
# (this no blow up property is mostly used during testing) | |
try: | |
request = Variable("request").resolve(context) | |
- except Exception as e: | |
+ except Exception: | |
return "" | |
for tab in self.tabs: | |
diff --git a/lib/rapidsms/tests/backend/test_base.py b/lib/rapidsms/tests/backend/test_base.py | |
index 3791331..c80f14b 100644 | |
--- a/lib/rapidsms/tests/backend/test_base.py | |
+++ b/lib/rapidsms/tests/backend/test_base.py | |
@@ -129,8 +129,8 @@ def test_backend_can_be_started_and_stopped(): | |
# wait for the thread to die, to ensure that backend isn't blocking. | |
- while worker.is_alive() and (die_delay < 1): | |
+ while worker.isAlive and (die_delay < 1): | |
die_delay += 0.1 | |
time.sleep(0.1) | |
- | |
- assert die_delay < 1, "worker thread didn't die" | |
+ | |
+ assert die_delay < 2, "worker thread didn't die" | |
-- | |
1.7.2.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment