Example #1
0
File: ljcs.py Project: sa2ajj/ljpy
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)

info = lj.login (username, password)

sfrom = list2mask (options.sfrom, info.friendgroups)
Example #2
0
File: ljac.py Project: sa2ajj/ljpy
from locale import getdefaultlocale

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

lang, defaultenc = getdefaultlocale ()

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

parser.add_option ('-e', '--encoding', type='string', dest='encoding', default = None,
                   help = 'specify character encoding',
                   metavar = 'ENCODING')

options, args = parser.parse_args ()

encoding = evalue (defaultenc, options.encoding)

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

server = getattr (config, options.server)
ljac = config.ljac

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)
Example #3
0
File: ljp.py Project: sa2ajj/ljpy
    parser.add_option ('-M', '--music',
                    action = 'store', type = 'string', dest = 'music', default = None,
                    help = 'tell them what music you are listening to',
                    metavar = 'MUSIC')
    parser.add_option ('-b', '--batch',
                    action = 'store_true', dest = 'batch', default = None,
                    help = 'use in a batch mode: the text will be read from the standard input and posted right away')
    parser.add_option ('-i', '--include',
                    action = 'store', dest = 'draft', default = None,
                    help = 'specify the file, which contains the draft of the message (this option is avilable only in non-batch mode)',
                    metavar = 'FILE')

    options, args = parser.parse_args ()

    # MSS: i may want to be able to specify the encoding from the configuration file
    encoding = evalue (defaultenc, options.encoding)

    subject = options.subject

    if len (args) > 0:
        body = ' '.join (args)
    else:
        body = ''

    props = {}

    if options.options is not None:
        for option in list2list (options.options):
            if option in [ 'preformatted', 'nocomments', 'backdated', 'noemail' ]:
                props['opt_%s' % option] = 1
            else:
Example #4
0
def nicedatetime (what):
    return strftime ("%F %T", localtime (what))

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

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

parser.add_option ('-f', '--file', type='string', dest='file', default = 'lj.backup',
                   help = 'specify the file to store the backup to',
                   metavar = 'FILE')

options, args = parser.parse_args ()

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

server = getattr (config, options.server)
ljbackup = config.ljbackup

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)

backupname = evalue (ljbackup.file, options.file)

lj = LiveJournal (config.misc.version)
Example #5
0
File: lje.py Project: sa2ajj/ljpy
else:
    subject = None

props = {}

if options.preformatted:
    props['opt_preformatted'] = 1

if options.mood is not None:
    props['current_mood'] = options.mood

if options.music is not None:
    props['current_music'] = options.music

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

server = getattr (config, options.server)

lj = LiveJournal (config.misc.version)

info = lj.login (server.username, server.password)

if 0:
    if subject is not None:
        subject = unicode (subject, 'koi8-r')

    event = unicode (event, 'koi8-r')

    entry = lj.postevent (event,
                subject = subject,