当前位置: 首页>>代码示例>>Python>>正文


Python inventory.Inventory方法代码示例

本文整理汇总了Python中inventory.Inventory方法的典型用法代码示例。如果您正苦于以下问题:Python inventory.Inventory方法的具体用法?Python inventory.Inventory怎么用?Python inventory.Inventory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inventory的用法示例。


在下文中一共展示了inventory.Inventory方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import inventory [as 别名]
# 或者: from inventory import Inventory [as 别名]
def __init__(self, args, logger=None, mode=None):
    self.commandLine = CommandLine(args)
    if mode is not None:
      self.commandLine.mode = mode
    if logger is None:
      logging.basicConfig(format="%(asctime)-15s %(levelname)s [%(filename)s:%(lineno)d-%(thread)d] %(message)s")
      logger = logging.getLogger()
      logger.setLevel(logging.INFO)
    self.logger = logger

    self.mode = self.__detectMode(self.commandLine.mode)
    self.config = self.__loadConfig()
    self.inventory = Inventory(logger, self.config)
    self.commands = { 
      'migrate': MigrateCommand(self),
      'list-migrations': ListMigrationsCommand(self),
      'version': VersionCommand(self),
      'help':HelpCommand(self) }
    self.defaultCommand = HelpCommand(self) 
开发者ID:server-mechanic,项目名称:mechanic,代码行数:21,代码来源:context.py

示例2: __init__

# 需要导入模块: import inventory [as 别名]
# 或者: from inventory import Inventory [as 别名]
def __init__(self, session, authProvider, accessToken, location):
        self.session = session
        self.authProvider = authProvider
        self.accessToken = accessToken
        self.location = location
        if self.location.noop:
            logging.info("Limited functionality. No location provided")

        self._state = State()

        self.authTicket = None
        self.endpoint = None
        self.endpoint = 'https://{0}{1}'.format(
            self.createApiEndpoint(),
            '/rpc'
        )

        # Set up Inventory
        self.getInventory() 
开发者ID:cglatot,项目名称:PokeManager,代码行数:21,代码来源:session.py

示例3: parseDefault

# 需要导入模块: import inventory [as 别名]
# 或者: from inventory import Inventory [as 别名]
def parseDefault(self, res):
        try:
            self._state.eggs.ParseFromString(res.returns[1])
            self._state.inventory.ParseFromString(res.returns[2])
            self._state.badges.ParseFromString(res.returns[3])
            self._state.settings.ParseFromString(res.returns[4])
        except Exception as e:
            logging.error(e)
            raise GeneralPogoException("Error parsing response. Malformed response")

        # Finally make inventory usable
        item = self._state.inventory.inventory_delta.inventory_items
        self.inventory = Inventory(item)

    # Hooks for those bundled in default
    # Getters 
开发者ID:cglatot,项目名称:PokeManager,代码行数:18,代码来源:session.py

示例4: setUp

# 需要导入模块: import inventory [as 别名]
# 或者: from inventory import Inventory [as 别名]
def setUp(self):
      logger = MagicMock()
      config = MagicMock()
      self.inventory = Inventory(logger=logger, config=config)
      self.inventoryDb = MagicMock()
      self.inventory.inventoryDb = self.inventoryDb
      tempDir = tempfile.mkdtemp()
      config.migrationDirs = [tempDir]
      config.preMigrationDirs = [tempDir]
      config.postMigrationDirs = [tempDir] 
开发者ID:server-mechanic,项目名称:mechanic,代码行数:12,代码来源:inventory_test.py

示例5: run

# 需要导入模块: import inventory [as 别名]
# 或者: from inventory import Inventory [as 别名]
def run(self, inventory=None):

        if inventory is not None:
            self.inventory = inventory

        try:
            if isinstance(self.inventory, Inventory):
                self.inventory.to_file(self.inventory_path)
                self.logger.debug("Saved inventory file to %s" % self.inventory_path)

            return self._run()

        finally:
            self.cleanup() 
开发者ID:OpenDataAnalytics,项目名称:dauber,代码行数:16,代码来源:playbook.py

示例6: cleanup

# 需要导入模块: import inventory [as 别名]
# 或者: from inventory import Inventory [as 别名]
def cleanup(self):
        if isinstance(self.inventory, Inventory):
            try:
                os.remove(self.inventory_path)
                self.logger.debug("Cleaned up %s" % self.inventory_path)
            except IOError:
                pass

            self._inventory_path = None 
开发者ID:OpenDataAnalytics,项目名称:dauber,代码行数:11,代码来源:playbook.py

示例7: inventory_path

# 需要导入模块: import inventory [as 别名]
# 或者: from inventory import Inventory [as 别名]
def inventory_path(self):
        if self._inventory_path is None:
            if isinstance(self.inventory, basestring):
                self._inventory_path = self.inventory
            elif isinstance(self.inventory, Inventory):
                _, self._inventory_path  = tempfile.mkstemp()

        return self._inventory_path 
开发者ID:OpenDataAnalytics,项目名称:dauber,代码行数:10,代码来源:playbook.py

示例8: getDefaults

# 需要导入模块: import inventory [as 别名]
# 或者: from inventory import Inventory [as 别名]
def getDefaults():
        # Allocate for 4 default requests
        data = [None, ] * 4

        # Create Egg request
        data[0] = Request_pb2.Request(
            request_type=RequestType_pb2.GET_HATCHED_EGGS
        )

        # Create Inventory Request
        data[1] = Request_pb2.Request(
            request_type=RequestType_pb2.GET_INVENTORY,
            request_message=GetInventoryMessage_pb2.GetInventoryMessage(
                last_timestamp_ms=0
            ).SerializeToString()
        )

        # Create Badge request
        data[2] = Request_pb2.Request(
            request_type=RequestType_pb2.CHECK_AWARDED_BADGES
        )

        # Create Settings request
        data[3] = Request_pb2.Request(
            request_type=RequestType_pb2.DOWNLOAD_SETTINGS,
            request_message=DownloadSettingsMessage_pb2.DownloadSettingsMessage(
                hash="4a2e9bc330dae60e7b74fc85b98868ab4700802e"
            ).SerializeToString()
        )

        return data

    # Parse the default responses 
开发者ID:cglatot,项目名称:PokeManager,代码行数:35,代码来源:session.py

示例9: load

# 需要导入模块: import inventory [as 别名]
# 或者: from inventory import Inventory [as 别名]
def load(cls, vnum: int=None, instance_id: int=None):
        if instance_id:
            if instance_id in instance.rooms:
                logger.warn('Instance %d of room already loaded!', instance_id)
                return
            pathname = settings.INSTANCE_DIR
            number = instance_id
        elif vnum:
            pathname = settings.AREA_DIR
            number = vnum
        else:
            raise ValueError('To load a Room, you must provide either a VNUM or an Instance_ID!')

        if settings.SAVE_FORMAT['Pickle'][0]:
            target_file = '%d-room%s' % (number, settings.SAVE_FORMAT['Pickle'][1])
        elif settings.SAVE_FORMAT['JSON'][0]:
            target_file = '%d-room%s' % (number, settings.SAVE_FORMAT['JSON'][1])
        else:
            target_file = '%d-room.json' % (number,)
        filename = None
        for a_path, a_directory, i_files in os.walk(pathname):
            if target_file in i_files:
                filename = os.path.join(a_path, target_file)
                break
        if not filename:
            raise ValueError('Cannot find %s' % target_file)
        jso = ''
        if settings.SAVE_FORMAT['JSON'][0]:
            #json version
            with open(filename, 'r+') as f:
                #this reads in one line at a time from stdin - way faster. Syn
                for line in f:
                    jso += line
        else:
            #pickle version
            import pickle
            with open(filename, 'rb') as f:
                jso = pickle.load(f)
        obj = json.loads(jso, object_hook=instance.from_json)
        if isinstance(obj, Room):
            # Inventory is already loaded by Room's __init__ function.
            return obj
        else:
            logger.error('Could not load room data for %d', number)
            return None 
开发者ID:bodrich,项目名称:pyom_mud,代码行数:47,代码来源:handler_room.py


注:本文中的inventory.Inventory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。