From patchwork Mon Mar 21 17:33:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guilherme Salgado X-Patchwork-Id: 87804 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id A6629B6F76 for ; Tue, 22 Mar 2011 04:33:35 +1100 (EST) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by ozlabs.org (Postfix) with ESMTP id 845F0B6EFF for ; Tue, 22 Mar 2011 04:33:34 +1100 (EST) Received: from youngberry.canonical.com ([91.189.89.112]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Q1iyy-0002nK-Ka; Mon, 21 Mar 2011 17:33:32 +0000 Received: from [187.126.146.36] (helo=feioso) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1Q1iyy-0006XD-BC; Mon, 21 Mar 2011 17:33:32 +0000 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by feioso (Postfix) with ESMTP id 4F017418B4; Mon, 21 Mar 2011 13:33:29 -0400 (EDT) Subject: [PATCH] New module to set appropriate sys.path for scripts. To: patchwork@lists.ozlabs.org From: Guilherme Salgado Date: Mon, 21 Mar 2011 14:33:29 -0300 Message-ID: <20110321173329.6569.61360.stgit@localhost6.localdomain6> User-Agent: StGit/0.15 MIME-Version: 1.0 Cc: patches@linaro.org X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org This is so that we don't have to write a wrapper shell script for every python script we have in app/patchwork/bin/. Signed-off-by: Guilherme Salgado --- apps/patchwork/bin/_pythonpath.py | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) create mode 100644 apps/patchwork/bin/_pythonpath.py diff --git a/apps/patchwork/bin/_pythonpath.py b/apps/patchwork/bin/_pythonpath.py new file mode 100644 index 0000000..0d8845d --- /dev/null +++ b/apps/patchwork/bin/_pythonpath.py @@ -0,0 +1,15 @@ +"""Add the /apps and /lib/python directories to +sys.path. + +Also sets the DJANGO_SETTINGS_MODULE environment variable to 'settings'. +""" +import os +import sys + + +patchwork_bin = os.path.dirname(__file__) +patchwork_base = os.path.abspath( + os.path.join(patchwork_bin, '..', '..', '..')) +sys.path.insert(0, '%s/lib/python' % patchwork_base) +sys.path.insert(0, '%s/apps' % patchwork_base) +os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'