keystone entrance manage.py

/opt/stack/keystone/keystone/cmd/manage.py

All projects are based on OpenStack Python development, and are standard Python project, by setuptools project management tool, responsible for the installation and distribution of Python modules. Want to know what services make up a project, the most direct and effective way is to find the entry function (main function) where, as long as the standard is based on setuptools project management functions of all entries will be defined in the project file setup.cfg root directory , is the entrance console_scripts all service components, such as the setup.cfg nova (Mitaka versions) console_scripts follows:

[entry_points]
...
console_scripts =

 

Enter the cd / opt / stack / keystone / keystone / cmd / directory, and then enter the command python python environment

python

import os
import sys

>>> os.getcwd () # the District the current directory
'/ opt / stack / keystone / keystone / cmd'

>>> dir1 = '/ opt / stack / keystone / keystone / cmd' # eligible zone file in the directory list
>>> the os.listdir (dir1)
[ '__init__.py', 'status.py', 'on Bootstrap .py ',' cli.pyc ',' doctor ',' manage.py ',' __init __. pyc ',' manage.pyc ',' cli.py ',' bootstrap.pyc ']

>>> print os.path.abspath ( 'manage.py') # attention parentheses file name requires quotation marks
/opt/stack/keystone/keystone/cmd/manage.py
>>> os.path.abspath ( 'manage.py')
'/opt/stack/keystone/keystone/cmd/manage.py'
>>>

>>> possible_topdir = os.path.normpath(os.path.join(os.path.abspath('manage.py'),
... os.pardir,
... os.pardir,
... os.pardir))
>>> possible_topdir
'/opt/stack/keystone'
>>> os.pardir
'..'
>>>

>>> dir2 = os.path.join(possible_topdir, 'keystone','__init__.py')
>>> dir2
'/opt/stack/keystone/keystone/__init__.py'
>>>

>>> os.path.exists('/opt/stack/keystone/keystone/__init__.py')
True
>>>

>>> sys.path.insert (0, possible_topdir) # end result is added to sys.path in / opt / stack / keystone of this path, to the list at the specified index to insert elements sys.path. INSERT (0 , possible_topdir )

>>> sys.path #是一个列表
['', '/opt/stack/keystone', '/opt/stack/cinder', '/opt/stack/neutron', '/opt/stack/nova', '/opt/stack/placement', '/opt/stack/horizon', '/opt/stack/glance', '/opt/stack/tempest', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']
>>>

SYS >>>. The argv # returns an empty list
[ '']

 

/opt/stack/keystone/keystone/cmd/cli.py call cli.py in the main function by manage.py

/ usr / local / Li B / python2.7 / dist-Packages can be found in oslo

 

Guess you like

Origin www.cnblogs.com/yitongtianxia59/p/11843271.html