Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1099ef9

Browse filesBrowse files
committed
Commands can run in any subdirectory of the app
1 parent f941d8e commit 1099ef9
Copy full SHA for 1099ef9

File tree

Expand file treeCollapse file tree

3 files changed

+37
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+37
-3
lines changed
Open diff view settings
Collapse file

‎dev_server/dev_server.py‎

Copy file name to clipboardExpand all lines: dev_server/dev_server.py
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@
1313
import yaml
1414
from optparse import OptionParser
1515

16-
app_root = os.getcwd()
16+
from sae.util import search_file_bottom_up
17+
18+
app_root = search_file_bottom_up('config.yaml')
19+
if app_root is None:
20+
print >> sys.stderr, \
21+
'Error: Not an app directory(or any of the parent directories)'
22+
sys.exit(1)
23+
if app_root != os.getcwd(): os.chdir(app_root)
1724

1825
def setup_sae_environ(conf):
1926
# Add dummy pylibmc module
Collapse file

‎dev_server/sae/util.py‎

Copy file name to clipboardExpand all lines: dev_server/sae/util.py
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,18 @@ def protect_secret(d):
1313
for k, v in d.items():
1414
if 'KEY' in k:
1515
half_secret(d, k)
16+
17+
import os.path
18+
19+
def search_file_bottom_up(name):
20+
curdir = os.getcwd()
21+
22+
while True:
23+
path = os.path.join(curdir, name)
24+
if os.path.isfile(path):
25+
return curdir
26+
_curdir = os.path.dirname(curdir)
27+
if _curdir == curdir:
28+
return None
29+
curdir = _curdir
30+
Collapse file

‎dev_server/saecloud‎

Copy file name to clipboardExpand all lines: dev_server/saecloud
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import hashlib
1515
import urllib
1616
import urllib2
1717

18+
from sae.util import search_file_bottom_up
19+
1820
UPLOAD_SERVER = 'http://upload.sae.sina.com.cn'
1921
DEPLOY_SERVER = 'http://deploy.sae.sina.com.cn'
2022
SVN_SERVER = 'https://svn.sinaapp.com/'
@@ -54,6 +56,13 @@ def deploy(args):
5456
opts = _get_svn_opts(args)
5557
cache = LOCAL_CACHE_DIR
5658

59+
if source is None:
60+
source = search_file_bottom_up('config.yaml')
61+
if source is None:
62+
print >>sys.stderr, \
63+
'Error: Not an app directory(or any of the parent directories)'
64+
return
65+
5766
conf_file = os.path.join(source, 'config.yaml')
5867
try:
5968
conf = yaml.load(open(conf_file))
@@ -313,7 +322,10 @@ def upload_data(args):
313322
uploadfile2(f, (appname, accesskey, secretkey), domain)
314323

315324
def install(args):
316-
dest = os.path.join(os.getcwd(), 'site-packages')
325+
# If we are in an app directory, try to install the package in the
326+
# standard directory.
327+
parent_dir = search_file_bottom_up('config.yaml') or os.getcwd()
328+
dest = os.path.join(parent_dir, 'site-packages')
317329

318330
if not os.path.exists(dest):
319331
os.mkdir(dest)
@@ -379,7 +391,7 @@ def main():
379391

380392
p = subparsers.add_parser('deploy', parents=[credentials],
381393
help='deploy source directory to SAE')
382-
p.add_argument('dir', nargs='?', default='.',
394+
p.add_argument('dir', nargs='?', default=None,
383395
help='the source code directory to deploy, default to current dir')
384396
p.set_defaults(func=deploy)
385397

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.