bpy.services package

Submodules

bpy.services.base module

Base recognizes no options, it’s only used for generate or checklink commands.

class bpy.services.base.Service(options, filename=None)[source]

Bases: object

The base clase of markup handler

generate()[source]
make_handler_post()[source]
post()[source]

Publish the post to the service

search(q)[source]

Search posts

service_name = 'base'

bpy.services.blogger module

Blogger service recognizes the following options in brc.py:

service = 'blogger'
service_options = {
  client_id: '<your client ID>',
  client_secret: '<your client secret>',
  'blog': <blog id>,
}

You can use blogs command to quickly get the blog ID.

Authorization

You need to authorize b.py to access your Blogger account with your OAuth client ID. Simply using blogs command (see Commands section) to start the authorization process:

b.py blogs

Once you follow the prompted steps, there should be a b.dat created under the current working directory, you should keep it safe.

Client ID

You will need to obtain a OAuth Client ID in order to use b.py.

  1. Go to Google Developers Console.
  2. Create a new project.
  3. Enable Blogger API.
  4. Create a OAuth client ID credential with Other application type.
  5. Download the credential JSON for Client Secret.
  6. Add Client ID and Client Secert to your brc.py as shown here.

b.dat

b.dat is a credential file for Blogger service, it’s read by b.py from the current directory.

To create the file, please follow Authorization.

class bpy.services.blogger.Service(*args, **kwargs)[source]

Bases: bpy.services.base.Service

auth()[source]
list_blogs()[source]
post()[source]
search(q)[source]
service_name = 'blogger'
class bpy.services.blogger.Storage(filename)[source]

Bases: oauth2client.file.Storage

Inherit the API Storage to suppress CredentialsFileSymbolicLinkError

bpy.services.wordpress module

WordPress service recognizes the following options in brc.py:

service = 'wordpress'
service_options = {
  'blog': <blog url>,
  'username': 'user01',
  'password': 'secret',
}

blog should be the URL of WordPress blog, for example, http://<something>.wordpress.com/ or http://example.com/wordpress/. Note that the tailing slash must be included.

In order to use WordPress XML-RPC API, you must provide username and password.

class bpy.services.wordpress.Service(*args, **kwargs)[source]

Bases: bpy.services.base.Service

auth()[source]
make_handler_post()[source]
post()[source]
service_name = 'wordpress'

Module contents

Services’ IDs:

service IDs
Base base
Blogger b, blogger
WordPress wp, wordpress

Options

To assign options to chosen service, add service_options in brc.py, for example:

service = "<service id>"
service_options = {
  'option1': 'value1',
  'option2': 2,
}

Writing a custom service

A sample handler sample_service.py:

from bpy.service import base

class Service(base.Service):

  # see bpy/services for examples
  pass

And corresponding setting in brc.py:

import re

# this matches the re
service = 'foobar'

services = {
  'SampleService': {
    'match': re.compile(r'^foobar$'),
    'module': 'sample_service',
  },
}
bpy.services.find_service(service_name, service_options, *args, **kwargs)[source]