Browse files

new fixes while testing

  • Loading branch information...
1 parent 051e778 commit 10b53e32721c66ca307b1423699ac077dfa969c7 unknown committed Nov 28, 2009
Showing with 34 additions and 28 deletions.
  1. +1 −2 contrib/win32/couchapp.iss
  2. +8 −5 couchapp/app.py
  3. +3 −3 couchapp/commands.py
  4. +20 −16 couchapp/couchdbresource.py
  5. +2 −2 couchapp/extensions.py
View
3 contrib/win32/couchapp.iss
@@ -16,7 +16,7 @@ DefaultDirName={pf}\Couchapp
DefaultGroupName=Couchapp
LicenseFile=LICENSE
InfoAfterFile=contrib\win32\postinstall.txt
-OutputBaseFilename=couchapp-0.5-installer
+OutputBaseFilename=couchapp-0.5
Compression=lzma
SolidCompression=yes
SourceDir=..\..
@@ -65,4 +65,3 @@ Filename: {app}\add_path.exe; Parameters: {app}; Description: Add the installati
[UninstallRun]
Filename: {app}\add_path.exe; Parameters: /del {app}
-
View
13 couchapp/app.py
@@ -57,11 +57,14 @@ def clone(ui, source, dest=None, rev=None):
dburl, docid = source.split('_design/')
except ValueError:
raise AppError("%s isn't a valid source" % source)
-
- if dest is None: dest = docid
-
+
+ if not dest:
+ dest = docid
+
path = os.path.normpath(os.path.join(os.getcwd(), dest))
-
+ if not os.path.exists(path):
+ os.makedirs(path)
+
db = client.Database(ui, dburl)
if not rev:
doc = db.get_doc("_design/%s" % docid)
@@ -265,4 +268,4 @@ def vendor_install(ui, dest, source, *args, **opts):
def vendor_update(ui, dest, name=None, *args, **opts):
vendor = Vendor(ui)
vendor.update(dest, name, *args, **opts)
-
+
View
6 couchapp/commands.py
@@ -165,10 +165,10 @@ def pushdocs(ui, source, dest, *args, **opts):
return 0
def clone(ui, source, *args, **opts):
- if len(args) >= 1:
+ if len(args) > 0:
dest = args[0]
else:
- dest = "."
+ dest = None
hooks.hook(ui, dest, "pre-clone", source=source)
app.clone(ui, source, dest, rev=opts.get('rev'))
hooks.hook(ui, dest, "post-clone", source=source)
@@ -346,4 +346,4 @@ def print_option(opt):
}
withcmd = ['generate', 'vendor']
-incouchapp = ['init', 'push', 'generate', 'vendor']
+incouchapp = ['init', 'push', 'generate', 'vendor']
View
36 couchapp/couchdbresource.py
@@ -41,7 +41,7 @@
USER_AGENT = "couchapp/%s" % __version__
-DEFAULT_TIMEOUT = 300
+DEFAULT_TIMEOUT = 150
MAX_CONNECTIONS = 4
DEFAULT_UUID_BATCH_COUNT = 1000
STREAM_SIZE = 16384
@@ -285,26 +285,28 @@ def make_connection(self):
setattr(connection, "started", time.time())
return connection
-
+ def do_get(self):
+ if self.connections:
+ connection = self.connections.popleft()
+ return connection
+ else:
+ return self.make_connection()
+
def get(self):
while True:
- if self.connections:
- connection = self.connections.popleft()
- since = time.time() - connection.started
- if since < self.timeout:
- if connection._HTTPConnection__response:
- connection._HTTPConnection__response.read()
- return connection
- else:
- connection.close()
+ connection = self.do_get()
+ since = time.time() - connection.started
+ if since < self.timeout:
+ if connection._HTTPConnection__response:
+ connection._HTTPConnection__response.read()
+ return connection
else:
- return self.make_connection()
+ connection.close()
def put(self, connection):
- if len(self.connections) > self.max_connections:
+ if len(self.connections) >= self.max_connections:
connection.close()
return
-
if connection.sock is None:
connection = self.make_connection()
self.connections.append(connection)
@@ -343,11 +345,13 @@ def __init__(self, response, uri, connection, release_callback):
self.conn = connection
self.release_callback = release_callback
self.stream_size = STREAM_SIZE
+
def read(self, amt=None):
- data = self.resp.read(amt)
+ data = None
+ if not self.resp.isclosed():
+ data = self.resp.read(amt)
if not data:
- self.close()
self.release_callback(self.uri, self.conn)
return data
View
4 couchapp/extensions.py
@@ -66,7 +66,7 @@ def load_extension(ui, name, path):
# allow extensions to do some initial setup
setup = getattr(mod, 'setup', False)
- if uisetup:
+ if setup:
setup(ui)
def load_extensions(ui):
@@ -93,4 +93,4 @@ def load_extensions(ui):
load_extension(ui, name, path)
except Exception, e:
if ui.verbose >= 1:
- ui.logger.error("failed to import %s extension: %s" % (name, str(e)))
+ ui.logger.error("failed to import %s extension: %s" % (name, str(e)))

0 comments on commit 10b53e3

Please sign in to comment.