Browse files

Merge of some changes into the main tree. I may have screwed this up,…

… I'm still learning some of this git mgmt stuff
  • Loading branch information...
1 parent 8839573 commit 7e93dddce995678f8caae0a056c71ffcdffd23df @FarMcKon committed Apr 17, 2011
Showing with 334 additions and 329 deletions.
  1. +1 −1 .gitignore
  2. +201 −264 config.py
  3. +51 −0 config_helpers.py
  4. +58 −60 delicious_import.py
  5. +0 −4 example_settings.py
  6. +23 −0 gitmarks_exceptions.py
View
2 .gitignore
@@ -1,2 +1,2 @@
-baseline_settings.py
settings.py
+*.pyc
View
465 config.py
@@ -8,393 +8,330 @@
"""
import example_settings
+
+import sys
import os
import subprocess
import shutil
+from gitmarks_exceptions import InputError, SettingsError, GitError
+from config_helpers import get_int, get_string, get_yes_or_no
+
# Arguments are passed directly to git, not through the shell, to avoid the
# need for shell escaping. On Windows, however, commands need to go through the
# shell for git to be found on the PATH, but escaping is automatic there. So
# send git commands through the shell on Windows, and directly everywhere else.
USE_SHELL = os.name == 'nt'
+def main():
+ """Main"""
+
+ print """
+ Wecome to gitmarks configurator. This will setup a couple of local
+ repositories for you to use as your gitmarks system. Gitmarks will
+ maintain 2-3 repositories.
+ - 1 for public use (world+dog read)
+ - 1 for friends use (with some encryption)
+ - 1 (optional) for content. This can be non-repo, or nonexistant.
+ """
+
+ if not get_yes_or_no("Ready to start?"):
+ print "Goodbye! Share and Enjoy."
+ return 0
+
+ return configure_gitmarks()
+
+
def configure_gitmarks():
"""
This function does the basic configuration of gitmarks. It tries to
download needed software, get settings from users, and spawns the basic
on-disk files for the bookmarks.
"""
- # -- pull needed libraries from the net
+
+ # Pull needed libraries from Internet
download_needed_software()
- # -- generate our configuration settings
- dict = config_settings_from_user()
+ # Generate our configuration settings
+ user_settings = config_settings()
+
+ try:
+ cont = get_yes_or_no("Setup up local environment from " + \
+ "above settings?")
+ except InputError, err:
+ print str(err)
+ return -1
- cont = getYesNoFromUser("Setup up local environment from above settings?",
- True)
if not cont:
print "You must store settings in beta, can't continue without them."
- return 0
+ return -1
- # -- store updated settings to settings.py, and reload
- success = create_or_update_settings(dict, 'settings.py',
- 'example_settings.py')
- if success:
- # -- well, we got this far. Lets make some folders
- ret = create_local_gitmarks_folders()
- if ret:
- print "Setup complete."
- else:
- print "Problem creating local gitmarks folders, error: %d" % (ret)
- return ret
- else:
- print "Failed to store updated settings " + str(dict)
- return -5
+ # Store user settings in settings.py, use example_settings.py as starting
+ # point
+ create_or_update_settings(user_settings, 'settings.py',
+ 'example_settings.py')
+
+ create_local_gitmarks_folders()
+ print "Setup complete."
return 0
def download_needed_software():
+ """Not implemented"""
# wget http://python-gnupg.googlecode.com/files/python-gnupg-0.2.6.tar.gz
# or get gpg or pgp instead?
- print "TODO: Download prerequsite software"
pass
+def setup_repo(remote_repo, base_dir, local_dir, subdirs):
+ """
+ Setup repository in local directory and populate it with given
+ subdirectories
+ remote_repo - Name of remote repo
+ base_dir - Full path to base directory for repo
+ local_dir - Name of local directory (subdirectory within the base_dir
+ to put repo
+ subdirs - List of sub directories to populate repo with
+ """
+
+ repo_dir = os.path.join(base_dir, local_dir)
+
+ # If we have remote public repo, try to git-clone to create local copy.
+ if (remote_repo != None):
+ if not folder_is_git_repo(repo_dir):
+ ret = clone_to_local(base_dir, repo_dir, remote_repo)
+ if(ret != 0):
+ raise GitError("Remote public clone to local failed")
+
+ # No remote public repo, make a dir and git-init it as needed
+ else:
+ abs_repo_dir = os.path.abspath(repo_dir)
+
+ # Create a dir if we need to
+ if not os.path.isdir(abs_repo_dir):
+ os.makedirs(abs_repo_dir)
+
+ # Init the new git repo
+ ret = init_git_repo(abs_repo_dir)
+ if(ret != 0):
+ raise GitError("Initializing '%s' failed" % (abs_repo_dir))
+
+ # Create our sub-dirs
+ make_gitmark_subdirs(abs_repo_dir, subdirs)
+
+
def create_local_gitmarks_folders():
"""
This function creates local repository folders. If we have a remote
repo name, it will try to sync that data to this place. If the settings
remote repository info is "None" it will just create a local repo without a
remote connection.
+ - Raises GitError if problems cloning local repos
+ - Raises ImportError if unable to import settings.py
"""
# Now we can load the settings we just created
try:
import settings
- except ImportError, e:
+ except ImportError, err:
print "Failed loading settings.py module"
- raise e
+ raise err
abs_base_dir = os.path.abspath(settings.GITMARK_BASE_DIR)
- # -- Create a base directory if we need to
+ # List of subdirectories to populate repos with
+ subdirs = [settings.BOOKMARK_SUB_PATH, settings.TAG_SUB_PATH,
+ settings.MSG_SUB_PATH]
+
+ # Create a base directory if we need to
if not os.path.isdir(abs_base_dir):
- print " creating base directory for gitmarks"
+ print "Creating base directory, '%s', for gitmarks" % (abs_base_dir)
os.makedirs(abs_base_dir)
- public_gitmarks_dir = os.path.join(settings.GITMARK_BASE_DIR,
- settings.PUBLIC_GITMARK_REPO_DIR)
+ # Setup the public repo locally
+ setup_repo(settings.REMOTE_PUBLIC_REPO, settings.GITMARK_BASE_DIR,
+ settings.PUBLIC_GITMARK_REPO_DIR, subdirs)
- # -- if we have remote public repo, try to git-clone to create local copy.
- if(settings.REMOTE_PUBLIC_REPO != None):
- if not folder_is_git_repo(public_gitmarks_dir):
- ret = clone_to_local(settings.GITMARK_BASE_DIR,
- public_gitmarks_dir,
- settings.REMOTE_PUBLIC_REPO)
- if(ret != 0):
- print "remote public clone to local failed"
- return -9
+ # Setup the private repo locally
+ setup_repo(settings.REMOTE_PRIVATE_REPO, settings.GITMARK_BASE_DIR,
+ settings.PRIVATE_GITMARK_REPO_DIR, subdirs)
- # -- no remote public repo, make a dir and git-init it as needed
- else:
- abs_public_gitmarks_dir = os.path.abspath(public_gitmarks_dir)
-
- # -- create a dir if we need to.
- if not os.path.isdir(abs_public_gitmarks_dir):
- os.makedirs(abs_public_gitmarks_dir)
-
- # -- init the new git repo in that dir
- cwd_dir = os.path.abspath(os.getcwd())
- os.chdir(os.path.abspath(abs_public_gitmarks_dir))
- ret = subprocess.call(['git', 'init', '.', ], shell=USE_SHELL)
- os.chdir(cwd_dir)
-
- # -- create our sub-dirs if needed
- make_gitmark_subdirs(abs_public_gitmarks_dir,
- [settings.BOOKMARK_SUB_PATH,
- settings.TAG_SUB_PATH,
- settings.MSG_SUB_PATH])
-
- private_gitmarks_dir = os.path.join(settings.GITMARK_BASE_DIR,
- settings.PRIVATE_GITMARK_REPO_DIR)
-
- # -- if we have remote private repo, try to git-clone to create local copy.
- if(settings.REMOTE_PRIVATE_REPO != None):
- if not folder_is_git_repo(private_gitmarks_dir):
- ret = clone_to_local(settings.GITMARK_BASE_DIR,
- private_gitmarks_dir,
- settings.REMOTE_PRIVATE_REPO)
- if(ret != 0):
- print "remote public clone to local failed"
- return -9
-
- # -- no remote private repo, make a dir and git-init it as needed
- else:
- abs_private_gitmarks_dir = os.path.abspath(private_gitmarks_dir)
-
- # -- create a dir if we need to.
- if not os.path.isdir(abs_private_gitmarks_dir):
- os.makedirs(abs_private_gitmarks_dir)
-
- # -- init the new git repo in that dir
- cwd_dir = os.path.abspath(os.getcwd())
- os.chdir(os.path.abspath(abs_private_gitmarks_dir))
- ret = subprocess.call(['git', 'init', '.', ], shell=USE_SHELL)
- os.chdir(cwd_dir)
-
- # -- create our sub-dirs if needed
- make_gitmark_subdirs(abs_private_gitmarks_dir,
- [settings.BOOKMARK_SUB_PATH,
- settings.TAG_SUB_PATH,
- settings.MSG_SUB_PATH])
-
- # -- Create our local content directory and repo, even if we never use it
+ # Create our local content directory and repo, even if we never use it
content_dir = os.path.join(settings.GITMARK_BASE_DIR,
settings.CONTENT_GITMARK_DIR)
if not os.path.isdir(content_dir):
+ print "Creating content directory, '%s', for gitmarks" % (content_dir)
os.makedirs(content_dir)
- else:
- print 'content dir already exists at "' + str(content_dir) + '"'
- cwd_dir = os.path.abspath(os.getcwd())
- os.chdir(os.path.abspath(content_dir))
- ret = subprocess.call(['git', 'init', '.', ], shell=USE_SHELL)
- os.chdir(cwd_dir)
+ init_git_repo(content_dir)
- return 0
+def clone_to_local(base_dir, folder_name, remote_git_repo):
+ """Clones a repository at remote_git_repo to a local directory"""
-def clone_to_local(baseDir, folderName, remoteGitRepo):
- """Clones a repository at remoteGitRepo to a local directory"""
- print "cloning repository %s to directory %s" % (remoteGitRepo, folderName)
+ print "Cloning repository '%s' to directory '%s'" % (remote_git_repo,
+ folder_name)
#swizzle our process location so that we get added to the right repo
- baseDir = os.path.abspath(baseDir)
+ base_dir = os.path.abspath(base_dir)
cwd_dir = os.path.abspath(os.getcwd())
- os.chdir(os.path.abspath(baseDir))
- ret = subprocess.call(['git', 'clone', remoteGitRepo, folderName],
+ os.chdir(os.path.abspath(base_dir))
+ ret = subprocess.call(['git', 'clone', remote_git_repo, folder_name],
shell=USE_SHELL)
os.chdir(cwd_dir)
return ret
-def make_gitmark_subdirs(folderName, subdirsList):
+def init_git_repo(directory):
+ """Initalize git repo in directory (absolute path)"""
+
+ # Change directory and init
+ cwd_dir = os.path.abspath(os.getcwd())
+ os.chdir(os.path.abspath(directory))
+ ret = subprocess.call(['git', 'init', '.', ], shell=USE_SHELL)
+
+ # Change back to what we were
+ os.chdir(cwd_dir)
+
+ return ret
+
+
+def make_gitmark_subdirs(folder_name, subdirs_list):
""" makes a stack of gitmarks subdirectories at the folder listed """
- for newDir in subdirsList:
- newDir = os.path.join(folderName, newDir)
- newDir = os.path.abspath(newDir)
- os.makedirs('mkdir')
+ for new_dir in subdirs_list:
+ new_dir = os.path.join(folder_name, new_dir)
+ new_dir = os.path.abspath(new_dir)
+ os.makedirs(new_dir)
#TODO: appears git does not add empty dirs. If it did, we would add
# that here
return
-def folder_is_git_repo(folderName):
- git_folder = os.path.join(folderName, '/.git/')
+def folder_is_git_repo(folder_name):
+ """Determine if a given folder is a valid git repository"""
+ git_folder = os.path.join(folder_name, '/.git/')
return os.path.isdir(git_folder)
-def config_settings_from_user():
- """
- Returns dict of config settings set interactivly by user.
- - Returns none on error
- """
+def config_settings():
+ """Returns dict of config settings set interactivly by user"""
- print """
- Wecome to gitmarks configurator. This will setup a couple of local
- repositories for you to use as yor gitmarks system. Gitmarks will
- maintain 2-3 repositories.
- - 1 for public use (world+dog read)
- - 1 for friends use (with some encryption)
- - 1 (optional) for content. This can be non-repo, or nonexistant
- """
- ret = getYesNoFromUser("Ready to start?", True)
- if ret is None:
- print "invalid choice"
- return None
+ base_dir = get_string('What base directories do you want ' + \
+ 'for your repos?', example_settings.GITMARK_BASE_DIR)
- elif ret is False:
- print "Goodbye! Share and Enjoy."
- return None
-
- base_dir = getStringFromUser('What base directories do you want your ' + \
- 'repos?', example_settings.GITMARK_BASE_DIR)
-
- get_content = getYesNoFromUser('Do you want to pull down content of ' + \
- 'page when you download a bookmark?',
+ get_content = get_yes_or_no('Do you want to pull down ' + \
+ 'content of page when you download a bookmark?',
example_settings.GET_CONTENT)
- content_cache_mb = getIntFromUser('Do you want to set a maximum MB of ' + \
- 'content cache?',
+ content_cache_mb = get_int('Do you want to set a maximum MB ' + \
+ 'of content cache?',
example_settings.CONTENT_CACHE_SIZE_MB)
- remote_pub_repo = getStringFromUser('Specify remote git repository ' + \
+ remote_pub_repo = get_string('Specify remote git repository ' + \
'for your public bookmarks',
example_settings.REMOTE_PUBLIC_REPO)
- remote_private_repo = getStringFromUser('Specify remote git ' + \
+ remote_private_repo = get_string('Specify remote git ' + \
'repository for your private bookmarks?',
example_settings.REMOTE_PRIVATE_REPO)
remote_content_repo = None
- content_as_reop = getYesNoFromUser('Do you want your content folder ' + \
- 'to be stored as a repository?',
+ content_as_reop = get_yes_or_no('Do you want your content ' + \
+ 'folder to be stored as a repository?',
example_settings.CONTENT_AS_REPO)
if content_as_reop is True:
- remote_content_repo = getStringFromUser('What is git repository ' + \
- 'for your content?',
+ remote_content_repo = get_string('What is git ' + \
+ 'repository for your content?',
example_settings.REMOTE_CONTENT_REPO)
- print "-- Pointless Info --"
- fav_color = getStringFromUser('What is your favorite color?',
- example_settings.FAVORITE_COLOR)
- wv_u_swallow = getStringFromUser('What is the windspeed velocity of ' + \
- 'an unladen swallow?',
- example_settings.UNLADEN_SWALLOW_GUESS)
-
print "-- User Info --"
- user_name = getStringFromUser("What username do you want to use?",
+ user_name = get_string("What username do you want to use?",
example_settings.USER_NAME)
- user_email = getStringFromUser("What email do you want to use?",
+ user_email = get_string("What email do you want to use?",
example_settings.USER_EMAIL)
- machine_name = getStringFromUser("What is the name of this computer?",
+ machine_name = get_string("What is the name of this computer?",
example_settings.MACHINE_NAME)
- dict = {'GITMARK_BASE_DIR': base_dir, 'GET_CONTENT': get_content,
- 'CONTENT_CACHE_SIZE_MB': content_cache_mb,
- 'CONTENT_AS_REPO': content_as_reop,
- 'REMOTE_PUBLIC_REPO': remote_pub_repo,
- 'REMOTE_PRIVATE_REPO': remote_private_repo,
- 'SAVE_CONTENT_TO_REPO': content_as_reop,
- 'REMOTE_CONTENT_REPO': remote_content_repo,
- 'FAVORITE_COLOR': fav_color, 'UNLADEN_SWALLOW_GUESS': wv_u_swallow,
- "PUBLIC_GITMARK_REPO_DIR": example_settings.PUBLIC_GITMARK_REPO_DIR,
- 'PRIVATE_GITMARK_REPO_DIR': example_settings.PRIVATE_GITMARK_REPO_DIR,
- 'CONTENT_GITMARK_DIR': example_settings.CONTENT_GITMARK_DIR,
- 'BOOKMARK_SUB_PATH': example_settings.BOOKMARK_SUB_PATH,
- 'TAG_SUB_PATH': example_settings.TAG_SUB_PATH,
- 'MSG_SUB_PATH': example_settings.MSG_SUB_PATH,
- 'HTML_SUB_PATH': example_settings.HTML_SUB_PATH,
- 'USER_NAME': user_name,
- 'USER_EMAIL': user_email,
- 'MACHINE_NAME': machine_name}
- return dict
-
-
-def create_or_update_settings(dict, settings_filename, opt_example_file=None):
+ return {'GITMARK_BASE_DIR': base_dir,
+ 'GET_CONTENT': get_content,
+ 'CONTENT_CACHE_SIZE_MB': content_cache_mb,
+ 'CONTENT_AS_REPO': content_as_reop,
+ 'REMOTE_PUBLIC_REPO': remote_pub_repo,
+ 'REMOTE_PRIVATE_REPO': remote_private_repo,
+ 'SAVE_CONTENT_TO_REPO': content_as_reop,
+ 'REMOTE_CONTENT_REPO': remote_content_repo,
+ 'PUBLIC_GITMARK_REPO_DIR':
+ example_settings.PUBLIC_GITMARK_REPO_DIR,
+ 'PRIVATE_GITMARK_REPO_DIR':
+ example_settings.PRIVATE_GITMARK_REPO_DIR,
+ 'CONTENT_GITMARK_DIR': example_settings.CONTENT_GITMARK_DIR,
+ 'BOOKMARK_SUB_PATH': example_settings.BOOKMARK_SUB_PATH,
+ 'TAG_SUB_PATH': example_settings.TAG_SUB_PATH,
+ 'MSG_SUB_PATH': example_settings.MSG_SUB_PATH,
+ 'HTML_SUB_PATH': example_settings.HTML_SUB_PATH,
+ 'USER_NAME': user_name,
+ 'USER_EMAIL': user_email,
+ 'MACHINE_NAME': machine_name}
+
+
+def create_or_update_settings(user_settings, settings_filename,
+ opt_example_file=None):
"""
- Does some magic to read a settings file, and replace the values in-line,
- and then write the new values back to the settings file.
+ Default all settings to the ones in the example settings file (if exists)
+ and overwrite defaults with setting from user
"""
- if not (os.path.isfile(settings_filename)):
- if not (opt_example_file):
- print "No settings files, add example_settings.py or settings.py"
- exit(-10)
- shutil.copy(opt_example_file, settings_filename)
+ if not os.path.isfile(settings_filename) and not opt_example_file:
+ raise SettingsError("Add example_settings.py or settings.py")
+
+ # Default all user settings to example settings file if one is given
+ shutil.copy(opt_example_file, settings_filename)
fh = open(settings_filename, 'r')
raw_settings = fh.readlines()
fh.close()
+
+ # Lines to be written to settings file with mesh of default and user
+ # settings as requested
newlines = []
+ # Parse lines of settings file and override with user-supplied setting if
+ # it exists otherwise, leave the setting alone (all settings are defaulted
+ # with example above)
for line in raw_settings:
newline = line.rstrip()
- if '=' in line:
- comment = None
- val = None
- var = None
-
- print 'on line "' + newline + '"'
-
- if (line.split('#') < 1):
- comment = line.split('#')[-1]
- print '\thas comment ' + str(comment)
-
- var = line.split('=')[0]
- val = ''.join(line.split('=')[1:])
- var = var.lstrip().rstrip()
- val = val.lstrip().rstrip()
-
- print '\tupdating var ' + str(var) + ' old val ' + str(val)
-
- if var in dict:
- if type(dict[var]) is str:
- newline = var + " = '" + str(dict[var]) + "'"
- else:
- newline = var + " = " + str(dict[var])
+ # Skip comment lines and lines that don't have a setting specified
+ if line.startswith('#') or '=' not in line:
+ newlines.append(line)
+ continue
- if comment:
- newline += ' # ' + comment
+ # File is key=value format, but just need the key to see if the user
+ # specified it
+ var = line.split('=')[0].lstrip().rstrip()
- print 'updated line "' + newline + '"'
-
- else:
- print 'no update on "' + newline + '"'
+ # Overwrite default setting if user specified it otherwise just write
+ # default one
+ if var in user_settings:
+ if type(user_settings[var]) is str:
+ newline = var + " = '" + str(user_settings[var]) + "'"
+ else:
+ newline = var + " = " + str(user_settings[var])
newlines.append(newline)
+ # We better have written every line of the example file, otherwise we
+ # missed something and have a SW bug
if len(newlines) == len(raw_settings):
fh = open(settings_filename, 'w')
- #debugging fh = open(settings_filename +".tmp",'w')
fh.write('\n'.join(newlines))
fh.close()
- return True
else:
- print "settings size did not match! Abandon the ship!"
- return False
-
- return False
-
-
-def getIntFromUser(message, value=''):
- """
- Prompts a user for an input int. Uses the default value if no
- value is entered by the user. Uses default value of parse error happens
- """
- msg2 = ' '.join([message, ' (', str(value), ') (int): '])
- newValue = raw_input(msg2)
- if(newValue == "" or newValue == "\n"):
- return int(value)
-
- try:
- return int(newValue)
- except:
- print "int decode fail for " + str(newValue) + \
- " Using default value of" + str(value)
- return int(value)
-
- return None
-
-
-def getStringFromUser(message, value=''):
- """get a string value from the command line"""
- msg2 = ''.join([message, ' (', str(value), ') (string): '])
- value = raw_input(msg2)
- return value
-
-
-def getYesNoFromUser(message, value=''):
- """ get a yes/no value from the command line"""
- msg2 = ''.join([message, ' (', str(value), ') (Y,n): '])
- newValue = raw_input(msg2)
-
- if(newValue == "" or newValue == "\n"):
- return value
-
- if(newValue == 'Y' or newValue == 'Yes' or newValue == 'y'):
- return True
-
- elif(newValue == 'n' or newValue == 'no' or newValue == 'N'):
- return False
-
- return None
+ raise SettingsError("Settings size did not match")
if __name__ == '__main__':
- """ geneirc main statement"""
- configure_gitmarks()
+ sys.exit(main())
View
51 config_helpers.py
@@ -0,0 +1,51 @@
+
+
+"""
+Helpers for getting user input for configuration
+"""
+
+
+def get_int(message, value=''):
+ """
+ Prompts a user for an input int. Uses the default value if no
+ value is entered by the user. Uses default value of parse error happens
+ """
+ msg2 = ' '.join([message, ' (', str(value), ') (int): '])
+ new_value = raw_input(msg2)
+ if(new_value == "" or new_value == "\n"):
+ return int(value)
+
+ try:
+ return int(new_value)
+ except ValueError:
+ print "Invalid integer, '%s', using default value" % (str(new_value))
+ return int(value)
+
+
+def get_string(message, default):
+ """get a string value from the command line"""
+ msg2 = ''.join([message, ' (', str(default), ') (string): '])
+ value = raw_input(msg2)
+
+ if not len(value):
+ return default
+
+ return value
+
+
+def get_yes_or_no(message, value=True):
+ """Get yes/no value from the command line"""
+
+ msg2 = ''.join([message, ' (', str(value), ') (Y,n): '])
+ new_value = raw_input(msg2)
+
+ if(new_value == "" or new_value == "\n"):
+ return value
+
+ if(new_value == 'Y' or new_value == 'Yes' or new_value == 'y'):
+ return True
+
+ elif(new_value == 'n' or new_value == 'no' or new_value == 'N'):
+ return False
+
+ raise InputError("Please choose y/n")
View
118 delicious_import.py
@@ -7,19 +7,19 @@
Copyright (c) 2010 Hilary Mason. All rights reserved.
"""
-import sys, os
-import urllib2
+import sys
+import urllib
from xml.dom import minidom
from xml.parsers import expat
-from optparse import OptionParser
-from gitmark import *
-from gitmark_add import *
+from gitmark import gitmark
+from gitmark_add import addToRepo, addToPublicRepo
def cache_to_local_file(local_file, content):
- h = open(local_file, 'w')
- h.write(content)
- h.close()
+ """Save content in local file"""
+ h = open(local_file, 'w')
+ h.write(content)
+ h.close()
def import_delicious_to_local_git(username, password='', url=None):
@@ -55,8 +55,7 @@ def import_delicious_to_local_git(username, password='', url=None):
if(fh):
fh.write(content)
fh.close()
- print "Saved problematic file as %s" % (saveFile)
-
+ print "Saved problematic file as %s" % (saveFile)
return
# sample post: <post href="http://www.pixelbeat.org/cmdline.html" hash="e3ac1d1e4403d077ee7e65f62a55c406" description="Linux Commands - A practical reference" tag="linux tutorial reference" time="2010-11-29T01:07:35Z" extended="" meta="c79362665abb0303d577b6b9aa341599" />
@@ -107,58 +106,57 @@ def import_delicious_to_local_git(username, password='', url=None):
err = addToRepo(mark,doPush=False)
print "mark add error %s" %str(err)
+
# -- hack test main for when yahoo sucks and I need to test
if __name__ == '__offfline_main__':
+ x = {"extended": "",
+ "hash": "082d479d946d5e9ebd891509446d9cbc",
+ "description":
+ "SSH and SCP: Howto, tips & tricks \u00ab Linux Tutorial Blog",
+ "rights": None,
+ "creator": "delicious:farmckon",
+ "uri": "http://www.linuxtutorialblog.com/post/ssh-and-scp-howto-tips-tricks",
+ "private": False,
+ "meta": "09f8b3205ee44cac3a94305db4337a7b",
+ "time": "2011-02-05T21:16:48Z",
+ "tags": [
+ "ssh",
+ "scp",
+ "linux_tutorial",
+ "howto"]}
+
+ g = gitmark(x['uri'], x['creator'])
+ g.description = x['description']
+ g.tags = x['tags']
+ g.time = x['time']
+ g.rights = None
+ g.meta = x["meta"]
+ g.extended = x['extended']
+ g.private = x['private']
+ addToPublicRepo(g)
- x = { "extended": "",
- "hash": "082d479d946d5e9ebd891509446d9cbc",
- "description": "SSH and SCP: Howto, tips & tricks \u00ab Linux Tutorial Blog",
- "rights": None,
- "creator": "delicious:farmckon",
- "uri": "http://www.linuxtutorialblog.com/post/ssh-and-scp-howto-tips-tricks",
- "private": False,
- "meta": "09f8b3205ee44cac3a94305db4337a7b",
- "time": "2011-02-05T21:16:48Z",
- "tags": [
- "ssh",
- "scp",
- "linux_tutorial",
- "howto"
- ]
-}
-
- g = gitmark(x['uri'], x['creator'])
- g.description = x['description']
- g.tags = x['tags']
- g.time = x['time']
- g.rights = None
- g.meta = x["meta"]
- g.extended = x['extended']
- g.private = x['private']
- addToPublicRepo(g)
-
-
-# -- real main.
-
if __name__ == '__main__':
-
- usage = "Usage: python delicious_import.py cached-page-uri\nOR\nUsage: python delicious_import.py username password\n***Password and username are sent as HHTTPS***"
-
- if( len(sys.argv) == 2):
- import getpass
- import socket
- username = getpass.getuser()
- host = socket.gethostname()
- username = '%s@%s' %(str(username), str(host))
-
- import_delicious_to_local_git(username, password=None, url=sys.argv[1])
- elif(len(sys.argv) == 3):
- try:
- (username, password) = sys.argv[1:]
- except ValueError:
- print usage
- import_delicious_to_local_git(username, password)
- else:
- print usage
-
+ usage = """
+ Usage: python delicious_import.py cached-page-uri
+ OR
+ Usage: python delicious_import.py username password
+ ***Password and username are sent as HTTPS***"
+ """
+
+ if (len(sys.argv) == 2):
+ import getpass
+ import socket
+
+ username = getpass.getuser()
+ host = socket.gethostname()
+ username = '%s@%s' % (str(username), str(host))
+ import_delicious_to_local_git(username, password=None, url=sys.argv[1])
+ elif (len(sys.argv) == 3):
+ try:
+ (username, password) = sys.argv[1:]
+ except ValueError:
+ print usage
+ import_delicious_to_local_git(username, password)
+ else:
+ print usage
View
4 example_settings.py
@@ -28,7 +28,3 @@
USER_NAME ="Example Name"
USER_EMAIL="ExampleName@example.com"
MACHINE_NAME="Example Computer Name"
-
-# Other Stuff
-FAVORITE_COLOR = "Red"
-UNLADEN_SWALLOW_GUESS = "I don't know"
View
23 gitmarks_exceptions.py
@@ -0,0 +1,23 @@
+# encoding: utf-8
+
+"""Gitmarks exception classes"""
+
+
+class GitmarksException(Exception):
+ """Base exception class"""
+ pass
+
+
+class InputError(GitmarksException):
+ """Exception raised for errors in user input."""
+ pass
+
+
+class SettingsError(GitmarksException):
+ """Exception raised for problems with settings files"""
+ pass
+
+
+class GitError(GitmarksException):
+ """Exception raised for problems with git setup"""
+ pass

3 comments on commit 7e93ddd

@durden
Collaborator

This merge looked ok, but the following revert stuff caused issues.

@durden
Collaborator

I'm a little confused why these config.py changes showed up again. I pushed them directly to your repo a few days ago. Is this just how github shows merge commits or something?

@FarMcKon
Owner
Please sign in to comment.