示例#1
0
文件: ljcs.py 项目: sa2ajj/ljpy
#! /usr/bin/python
# -*- coding: utf-8 -*-

from livejournal import LiveJournal, Config, evalue, list2mask
from livejournal.config import std_parser

parser = std_parser (usage = '%prog [options]')

parser.add_option ('-F', '--from',
                   action = 'store', type = 'string', dest = 'sfrom', default = 'public',
                   help = 'what security level change', metavar = 'SECURITY')
parser.add_option ('-T', '--to',
                   action = 'store', type = 'string', dest = 'sto', default = 'friends',
                   help = 'what security level change', metavar = 'SECURITY')

options, args = parser.parse_args ()

config = Config ()
config.load (evalue ('~/.ljrc', options.config))

server = getattr (config, options.server)

username = evalue (server.username, options.username)
password = evalue (server.password, options.password)

if username is None or password is None:
    print "You must provide both user name and password"
    sys.exit (2)

lj = LiveJournal (config.misc.version)
示例#2
0
文件: ljp.py 项目: sa2ajj/ljpy
__copyright__ = 'Copyright (c) 2002, 2003, 2004, 2005 Mikhail Sobolev'
__version__ = '$Revision$'
__date__ = '$Date$'

if __name__ == '__main__':
    import sys

    from locale import getdefaultlocale

    from livejournal import LiveJournal, list2list, list2mask, Config, evalue
    from livejournal.config import std_parser
    from livejournal.convert import args2text, text2args

    lang, defaultenc = getdefaultlocale ()

    parser = std_parser (usage = '%prog [options] [message text with spaces]')

    parser.add_option ('-e', '--encoding', type='string', dest='encoding', default = None,
                    help = 'specify character encoding',
                    metavar = 'ENCODING')
    parser.add_option ('-j', '--journal', type='string', dest='journal', default = None,
                    help = 'specify the journal to post to',
                    metavar = 'JOURNAL')
    parser.add_option ('-S', '--security',
                    action = 'store', type = 'string', dest = 'security', default = 'public',
                    help = 'restrict access to the item', metavar = 'SECURITY')
    parser.add_option ('-o', '--options',
                    action = 'store', type = 'string', dest = 'options', default = None,
                    help = 'list of options for the entry')
    parser.add_option ('-s', '--subject',
                    action = 'store', type = 'string', dest = 'subject', default = None,