Skip to main content

A package to import libraries remotely.

Project description

RemotePyLib

This is a package to use NalinStudios - RemotePyLib API.

It's Official Website: Visit
It's Official GitHub Page: Visit
It's Official PyPi Page: Visit
(It's Release History: Visit)

Usage

Firstly, you would have to install this package. To do so open up your Terminal/Command Prompt and type:

    ```shell

pip install RemotePyLib ```

Secondly, you would have to upload a module to the NalinStudios RemotePyLib API.

If you want to do so manually, go to the official website. Else if you wish to do so programmatically, follow the steps:

  • Create a python file to be exported in the directory of your main file.

  • In your main file, import the exporting class by:

    from RemotePyLib import Exporter
    
  • create and instance of the exporter object by:

    exporter = Exporter()
    
  • upload a file and get the key by:

    key = exporter.exportFile('myTestFile', 'modulename', 'myEmail@example.com')
    
  • the key should be kept secure so just print it by:

    print(key)
    
  • Or if you have a string value instead of a python file to be uploaded, replace

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

    With

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

    Note that this key will also be sent to the email address and if the email address is not valid, it will raise an InvalidEmailError (scroll down for reference) and if the email couldn't be reached, then the module uploaded will be taken down soon. Also, if the modulename already exists, then an ExportError (scroll down for reference) will be raised.

Here, the modulename and the key will be used to import/execute the remote modules.

Thirdly, You would have to import and use the module.

Follow the below steps:

  • import the importer class by:

    from RemotePyLib import Importer
    
  • create an instance of the importer object by:

    importer = Importer()
    
  • If your module is a script and does not need to be imported, use:

    importer.execModule('modulename', 'my_key')
    
  • Or if your module is needed to be imported, use:

    module = importer.importModule('modulename', 'my_key')
    
  • If you have imported the module you can use it's functions and attributes by:

    module.func(parameter1, parameter2, .....)
    value = module.variable
    myClass = module.MyClass()
    

If stuck, refer to the documentation below or add an issue in the issues section of the GitHub page

Classes

Importer

Desc.:

A class to remotely import packages using NalinStudios RemotePyLib API.

Functions:
  • execModule(self, modulename, key)
    This method is used to execute the remote module on the local machine.

      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)
    This method is used to import the remote module as a standard module.
    The classes and methods inside the remote module will work as if there was another python file along.
    Note that there should not be any python file with the same name as 'modulename' otherwise all the data in that file will be cleared.
    It returns the module object for the imported module.

      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

Desc.:

A class to export custom libraries to NalinStudios - RemotePyLib API.

Functions:
  • exportFile(self, filepath, modulename, email)
    Export a python file to the NalinStudios API.
    Returns the access key.
    Please keep the access key with you because it is required for importing the library. In case lost, contact the owner (go the the website and contact using email).

      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)
    Creates a remote library on NalinStudios - RemotePyLib API.
    It returns the access key.
    Please keep the access key with you because it is required for importing the library. In case lost, contact the owner (go the the website and contact using email).

      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)        
    

Exceptions

InvalidAccessError

cause:

Thrown when the key entered to access the remote module is incorrect.

solution:

Check the access key and try again.

RemoteModuleNotFoundError

cause:

Thrown when the name of the remote module to be imported could not be found.

solution:

Check the name of the module that is to be imported and try again.

ExportError

cause:

Thrown when the module could not be exported because another module with the same name was present on the server.

solution:

Try exporting the module using another name.

InvalidEmailError

cause:

Thrown when the email entered to upload the module using exporter is not valid.

solution:

Check the email address and try again.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

RemotePyLib-1.0.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

RemotePyLib-1.0.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file RemotePyLib-1.0.0.tar.gz.

File metadata

  • Download URL: RemotePyLib-1.0.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for RemotePyLib-1.0.0.tar.gz
Algorithm Hash digest
SHA256 391daa90e23020487b73ea613139d8f595ab0ac304cc50deaa56becf97794837
MD5 b89ac3bc1ccbbd4c3da98b1ca0a40f16
BLAKE2b-256 505998c8cfbf6d23852a8b49f0fba55fb2abd9a7eb9f6bd36faf233fe58309d0

See more details on using hashes here.

File details

Details for the file RemotePyLib-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: RemotePyLib-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for RemotePyLib-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d2ec91ba5752613d4f27867974c9dc93c7f4ab196192455044a2c3aad348ca8
MD5 e2f3ba74adf4a5d5f90f382b55e8d7ce
BLAKE2b-256 1880d5c062aa230964aa5097f42e83ff5be8befbed08b3c1a939c48b9d31ec16

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page