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


Python Utilities.show_warning方法代码示例

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


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

示例1: validate_setting

# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_warning [as 别名]
 def validate_setting(settings, option, norm_cb, msg):
     if settings.has_key(option):
         if norm_cb is not None:
             norm_cb(settings, option)
     else:
         if msg is not None:
             Utilities.show_warning("WB Administrator", msg, "OK", "", "")
         norm_cb(settings, option)
开发者ID:verflucht,项目名称:unlock_repo_feria,代码行数:10,代码来源:wb_admin_grt.py

示例2: GenerateDrupalSchema

# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_warning [as 别名]
def GenerateDrupalSchema(catalog):
  output = ''

  # Add all schema.
  for schema in catalog.schemata :
    hook_created = False
    comment_replace = {}

    # Collect the comment replacement strings.
    for table in schema.tables :
      comment_replace[(' %s table ' % table.name)] = ' {%s} table ' % table.name
      comment_replace[(' %s table.' % table.name)] = ' {%s} table.' % table.name

      for column in table.columns :
        comment_replace[(' %s.%s ' % (table.name, column.name))] = ' {%s}.%s ' % (table.name, column.name)
        comment_replace[(' %s.%s.' % (table.name, column.name))] = ' {%s}.%s.' % (table.name, column.name)

    # Add all tables.
    for table in schema.tables :
      if len(table.columns) > 0 :
        if not hook_created :
          ''' Create the hook '''
          if len(output) > 0 :
            output += "\n\n"

          output += "/**\n"
          output += " * Implements hook_schema().\n"
          output += " */\n"
          output += "function %s_schema() {\n" % re.sub(r'([^a-z0-9_]+|^[^a-z]+)', '', schema.name.lower().replace(' ', '_'))
          output += "  $schema = array();\n\n"
          hook_created = True

        ''' Add the table '''
        output += generateTableDefinition(table, comment_replace)
        output += "\n"

    if hook_created :
      ''' Close the hook '''
      output += "  return $schema;\n"
      output += '}'

  if len(output) > 0 :
    # Should the output be copied to the clipboard?
    answer = Utilities.show_message('Copy to clipboard?', "Would you like to copy the schema to your clipboard?\nIt can also be viewed in the output window.", 'Yes', 'No', '')
    if answer == mforms.ResultOk :
      grt.modules.Workbench.copyToClipboard(output)

    # MySQL specific fields warning.
    if "'mysql_type' => '" in output :
      Utilities.show_message('MySQL specific fields used', 'Note that the schema definition contains MySQL specific fields!', 'OK', '', '')

    print output
  else :
    Utilities.show_warning('No valid tables found', 'The schema was not generated because no valid tables were found.', 'OK', '', '')

  return 0
开发者ID:matthijs-va,项目名称:mysql-workbench-drupal-schema-generator,代码行数:58,代码来源:wb_drupal_schema.py

示例3: get_db_connection

# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_warning [as 别名]
def get_db_connection(server_instance_settings):
    if server_instance_settings.connection:
        db_connection = MySQLConnection(server_instance_settings.connection)
        ignore_error = False
        error_location = None
        the_error = None
        try:
            db_connection.connect()
        except MySQLError, exc:
         # errors that probably just mean the server is down can be ignored (ex 2013)
         # errors from incorrect connect parameters should raise an exception
         # ex 1045: bad password
            if exc.code in (1045,):
                raise exc
            elif exc.code in (2013,):
                ignore_error = True
            error_location = exc.location
            the_error = str(exc)

            if not ignore_error:
                if Utilities.show_warning("Could not connect to MySQL Server at %s" % error_location,
                        "%s\nYou can continue but some functionality may be unavailable." % the_error,
                        "Continue Anyway", "Cancel", "") != mforms.ResultOk:
                    raise MySQLError("", 0, "")
        return db_connection
开发者ID:verflucht,项目名称:unlock_repo_feria,代码行数:27,代码来源:wb_admin_utils.py

示例4: in

# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_warning [as 别名]
         # ex 1045: bad password
            if exc.code in (1045,):
                raise exc
            elif exc.code in (2013,):
                ignore_error = True
            error_location = exc.location
            the_error = str(exc)

            if not ignore_error:
                if Utilities.show_warning("Could not connect to MySQL Server at %s" % error_location,
                        "%s\nYou can continue but some functionality may be unavailable." % the_error,
                        "Continue Anyway", "Cancel", "") != mforms.ResultOk:
                    raise MySQLError("", 0, "")
        return db_connection
    else:
        Utilities.show_warning("WB Admin", "Server instance has no database connection specified.\nSome functionality will not be available.", "OK", "", "")


    return None




def weakcb(object, cbname):
    """Create a callback that holds a weak reference to the object. When passing a callback
    for mforms, use this to create a ref to it and prevent circular references that are never freed.
    """
    def call(ref, cbname):
        callback = getattr(ref(), cbname, None)
        if callback is None:
            print "Object has no callback %s"%cbname
开发者ID:verflucht,项目名称:unlock_repo_feria,代码行数:33,代码来源:wb_admin_utils.py


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