用于远程导入库的包。

RemotePyLib的Python项目详细描述


远程Pylib

这是一个使用NalinStudios-RemotePyLib API的包。在

官方网站:Visit
这是GitHub的官方页面:Visit
这是PyPi的官方页面:Visit
(发布历史:Visit

使用

首先,你必须安装这个软件包。为此,打开终端/命令提示符并键入:

pip install RemotePyLib

其次,您必须将一个模块上载到NalinStudios RemotePyLib API。在

如果您想手动操作,请访问官方网站。否则,如果希望以编程方式执行此操作,请执行以下步骤:

  • 在主文件的目录中创建要导出的python文件。在

  • 在主文件中,通过以下方式导入导出类:

    ^{pr2}$ 在
  • 通过以下方式创建导出器对象和实例:

    exporter=Exporter()
  • 上载文件并通过以下方式获取密钥:

    key=exporter.exportFile('myTestFile','modulename','myEmail@example.com')
  • 密钥应妥善保管,因此只需通过以下方式打印:

    print(key)
  • 或者,如果要上载的是字符串值而不是python文件,请替换

    key=exporter.exportFile('myTestFile','modulename','myEmail@example.com')

    key=exporter.exportString('StringValue','modulename','myEmail@example.com')

    请注意,此密钥也会发送到电子邮件地址,如果电子邮件地址无效,则会引发InvalidEmailError(向下滚动以供参考),如果无法访问电子邮件,则上载的模块将很快被删除。另外,如果modulename已经存在,那么将引发ExportError(向下滚动以供参考)。在

这里,modulename和key将用于导入/执行远程模块。在

第三,您必须导入并使用该模块。在

请执行以下步骤:

  • 导入导入器类的方法:

    fromRemotePyLibimportImporter
  • 通过以下方法创建导入器对象的实例:

    importer=Importer()
  • 如果模块是脚本,不需要导入,请使用:

    importer.execModule('modulename','my_key')
  • 或者,如果需要导入模块,请使用:

    module=importer.importModule('modulename','my_key')
  • 如果已导入模块,则可以通过以下方式使用模块的函数和属性:

    module.func(parameter1,parameter2,.....)value=module.variablemyClass=module.MyClass()

如果遇到问题,请参阅下面的文档或在GitHub页面的“问题”部分添加问题

Importer

说明:

一个使用NalinStudios RemotePyLib API远程导入包的类。在

功能:
  • execModule(self,modulename,key)
    此方法用于在本地计算机上执行远程模块。在

      Args:
          modulename (str): name of the module you have uploaded (The name is not surely the name of the python file you have uploaded. You would have entered a specific name in the 'name of module field' of the website).
          key (str): The access key given to you after you have uploaded the python module.
      Usage:
          importer = Importer()
          importer.execModule('module', 'key')  
    
  • importModule(self,modulename,key)
    此方法用于将远程模块作为标准模块导入。
    远程模块中的类和方法的工作方式就好像有另一个python文件一样。
    请注意,不应存在与“modulename”同名的python文件,否则该文件中的所有数据都将被清除。
    它返回导入模块的模块对象。在

      Args:
          modulename (str): name of the module you have uploaded (The name is not surely the name of the python file you have uploaded. You would have entered a specific name in the 'name of module field' of the website).
          key (str): The access key given to you after you have uploaded the python module.
      Usage:
          importer = Importer()
          module = importer.importModule('module', 'key')
          module.func()
          var = module.variable
          myClass = module.myClass()
    

Exporter

说明

将自定义库导出到NalinStudios-RemotePyLib API的类。在

功能:
  • 导出文件(self、filepath、modulename、email)
    将python文件导出到NalinStudios API。
    返回访问密钥。
    请随身携带访问密钥,因为它是导入库所必需的。如果丢失,请联系车主(访问网站并使用电子邮件联系)。在

      Args:
          filepath (str): path of the python file to be uploaded.
          modulename (str): name of the module with which it can be imported later.
          email (str): email address to recieve the key. If found invalid, then the module uploaded will be taken down.
      Usage:
          exporter = Exporter()
          key = exporter.exportFile('/mymodule.py', 'modulename', 'myemail@example.com')
          print(key)
    
  • exportString(self、content、modulename、email)
    在NalinStudios-RemotePyLib API上创建远程库。
    它返回访问密钥。
    请随身携带访问密钥,因为它是导入库所必需的。如果丢失,请联系车主(访问网站并使用电子邮件联系)。在

      Args:
          content (str): content to be placed in the remote library.
          modulename (str): name of the module with which it can be imported later.
          email (str): email address to recieve the key. If found invalid, then the module uploaded will be taken down.
      Usage:
          exporter = Exporter()
          key = exporter.exportString('print("Hello World!")', 'modulename', 'myemail@example.com')
          print(key)        
    

例外情况

InvalidAccessError

原因:

当输入用于访问远程模块的密钥不正确时引发。在

解决方案:

请检查访问密钥,然后重试。在

RemoteModuleNotFoundError

原因:

Thr找不到要导入的远程模块的名称时关闭。在

解决方案:

请检查要导入的模块的名称,然后重试。在

ExportError

原因:

由于服务器上存在另一个同名模块而无法导出模块时引发。在

解决方案:

尝试使用其他名称导出模块。在

InvalidEmailError

原因:

当输入的使用exporter上载模块的电子邮件无效时引发。在

解决方案:

请检查电子邮件地址并重试。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
使用Java将JSON转换为哈希映射   java如何通过使用MapStruct从源对象复制值来填充目标对象内部的映射?   注入泛型类型为@InjectGuice的类时发生java错误   字符串如何在JavaIDE中导入基本符号   在Java中将JSON转换为List<List<String>>   java Java9 HttpClient SSLHandshakeException   java jOOQ代码生成器   java如何调整图标(图像按钮),使其不会放大?   java我可以在使用Eclipse时安装2个或更多Android SDK吗   sqlite Java实现DAO   如何解决此错误?“java.lang.NoSuchFieldError:org.apache.http.conn.ssl.SSLConnectionSocketFactory上的实例。<clinit>。”   java Maven:将基于OSP的zip文件解压缩到WEBINF/lib   java如何在每次调用函数时获取当前gps位置?