GithubHelp home page GithubHelp logo

pygain's Introduction

Description

With this module has beed loaded, then we can "gain" any module on the fly. Because the python scripts can do almost anything that the C language can do, so with this module's power, we can throw upgrading away from now on.

Quickstart

1 - Put a python script on the website, I had put one at: http://oeb1qxnpc.bkt.clouddn.com/hello.py, the file's content is:

   #!/usr/bin/env python
   # -*- coding: utf-8 -*-
   # @author: zig([email protected])

   print("hello, pygain")

2 - Load this module from a local test script file "test.py", then "gain" the remote "hello.py":

   import pygain

   pygain.gain("hello", "http://oeb1qxnpc.bkt.clouddn.com", ["py"])

   import hello

3 - Execute the test script(tested from python2.6.6 to python3.5.2):

   > python test.py

if everything is fine, then we can see the "hello, pygain" was printed out

More reality: import zip package

"gain" remote script one by one is inefficient, so we can zip scripts together, let's do it

1 - Put a zip that contains some scripts, I had put one at: http://oeb1qxnpc.bkt.clouddn.com/demo.zip, the zip's content is:

demo.zip

/- init.py

/- hello.py

/- hello2.py

2 - Load this module from a local test script file "test.py", then "gain" the remote "demo.zip":

     import pygain

     pygain.gain("demo", "http://oeb1qxnpc.bkt.clouddn.com", ["zip", "py"])

     import demo.hello2

3 - Execute the test script(tested from python2.6.6 to python3.5.2)

   > python test.py

if everything is fine, then we can see the "hello, pygain" was printed out

4 - But we need only fetch the zip file, the scripts that embeded in the zip will import directly from the zip file.

Keyword arguments

Because of some special situation, we provider some keyword arguments, we can pass it on as below:

  pygain.gain("demo", "http://zagzig.me/pygain/demo/v1", ["zip", "py"],
    httpheaders={"Referer": "xxx"}, zippw="guesswhat")
  1. httpheaders: when we fetch the remote file, we can pass on some http headers

  2. zippw: the remote zip file can be encrypted, so pass this password to decrypt&load the remote zip module

Installation

   pip install pygain

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.