Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: appengine/path_mangler_hack.py

Issue 499103002: Make test_results deployable again. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix __exit__ arguments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import sys
6
7 # App Engine source file imports must be relative to their app's root.
8 # Provide a way to mangle sys.path, but not leave it littered with junk.
9
10 # TODO(ojan): This is a stopgap. Come up with a more general solution.
11
12 # pylint: disable=W0702
13
14 class PathMangler:
15 def __init__(self, root):
16 self.app_root = root
17
18 def __enter__(self):
19 sys.path.append(self.app_root)
20
21 try:
22 import model
23 reload(model)
24 except:
25 pass
26
27 try:
28 import handlers
29 reload(handlers)
30 except:
31 pass
32
33 def __exit__(self, etype, value, etraceback):
34 sys.path.remove(self.app_root)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698