personal cache change

1. catch exception during init
2. change local cache default path to home when
local disk is not available
diff --git a/repo b/repo
index 83ab888..6b57673 100755
--- a/repo
+++ b/repo
@@ -4,7 +4,7 @@
 ##
 REPO_URL = 'ssh://mtksgt08:29418/git-repo'
 REPO_REV = 'mediatek/dev'
-LOCAL_CACHE = '{user_home}/.git-objects'
+LOCAL_CACHE = '/git.cache/%s'
 
 # Copyright (C) 2008 Google Inc.
 #
@@ -767,8 +767,14 @@
         '--']
 
   if LOCAL_CACHE:
-    cache = LOCAL_CACHE.format(user_home=os.environ['HOME'])
-    orig_args.insert(0, '--local-cache=%s' % cache)
+    cache = LOCAL_CACHE % os.environ['USER']
+    if not os.path.exists(cache):
+        try:
+            os.makedirs(cache)
+            os.chmod(cache, 0700)
+        except OSError as e:
+            cache = '%s/.git.cache' % (os.environ['HOME'])
+    if cache: orig_args.insert(0, '--local-cache=%s' % cache)
 
   me.extend(orig_args)
   me.extend(extra_args)