CN109284112B - Method and device for running application program - Google Patents

Method and device for running application program Download PDF

Info

Publication number
CN109284112B
CN109284112B CN201811142996.4A CN201811142996A CN109284112B CN 109284112 B CN109284112 B CN 109284112B CN 201811142996 A CN201811142996 A CN 201811142996A CN 109284112 B CN109284112 B CN 109284112B
Authority
CN
China
Prior art keywords
container
application
application program
host
running
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811142996.4A
Other languages
Chinese (zh)
Other versions
CN109284112A (en
Inventor
贾思瑞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhengzhou Yunhai Information Technology Co Ltd
Original Assignee
Zhengzhou Yunhai Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhengzhou Yunhai Information Technology Co Ltd filed Critical Zhengzhou Yunhai Information Technology Co Ltd
Priority to CN201811142996.4A priority Critical patent/CN109284112B/en
Publication of CN109284112A publication Critical patent/CN109284112A/en
Application granted granted Critical
Publication of CN109284112B publication Critical patent/CN109284112B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation

Abstract

The invention discloses a method and a device for running an application program. The method comprises the following steps: packaging a Python environment developed when a first application program is developed on a first host computer into a container; wherein the container runs independently on a second host to which the first application is ported; compiling a Shell script; the Shell script is used for calling an inlet of a first application program by adopting a container so as to enable the first application program to run in the container; the Shell script, the container, and the first application are packaged as a compressed file running on the second host. Through the process, the first application program and the environment of the second host computer are not interacted, but run in the Python environment matched with the application program when the first application program is developed, and the purpose that the first application program still normally runs in the Python environment after being transplanted to the second host computer is achieved.

Description

Method and device for running application program
Technical Field
The present invention relates to container technology, and is especially method and apparatus for running application program.
Background
The Python language is widely used in the development process nowadays, and is powerful in function and numerous in modules, so that the development becomes very easy, but the developed program is very difficult to transplant, and the same set of program can normally run in the development environment, but the program cannot normally run due to various reasons (for example, no Python environment is installed in an operating system, or the version of the Python environment is inconsistent, or no dependent library is installed) when the Python language is transplanted in another host environment.
Disclosure of Invention
In order to solve the above technical problem, the present application provides a method and an apparatus for running an application, which enable a first application to run normally after being migrated to a host environment that is not a development environment.
In order to achieve the above object, an embodiment of the present invention provides a method for running an application, including the following steps:
packaging a Python environment developed when a first application program is developed on a first host computer into a container; wherein the container runs independently on a second host to which the first application is ported;
compiling a Shell script; the Shell script is used for calling an inlet of a first application program by adopting a container so as to enable the first application program to run in the container;
the Shell script, the container, and the first application are packaged as a compressed file running on the second host.
Further, in an optional embodiment, after the step of encapsulating the Shell script, the container, and the first application as a compressed file running on the second host, the method further comprises:
when an instruction to run the first application on the second host is received through the container, the container calls an entry of the first application to cause the first application to run in the container.
Further, in an alternative embodiment, the step of packaging the Python environment developed at the time of developing the first application on the first host as a container comprises:
the Python environment is packaged into a container in the format of an executable program.
Further, in an optional embodiment, after the step of encapsulating the Shell script, the container, and the first application as a compressed file running on the second host, the method further comprises:
and calling the entrances of other application programs except the first application program by the container according to the received instructions for running other application programs so as to run other application programs as a Python environment on the second host.
Further, in an alternative embodiment, the container is in the same level directory as the first application.
In order to achieve the above object, an embodiment of the present invention further provides an apparatus for running an application, where the apparatus includes a container encapsulation module, a script writing module, and a compressed file module; wherein the content of the first and second substances,
the container packaging module is used for: packaging a Python environment developed when a first application program is developed on a first host computer into a container; wherein the container runs independently on a second host to which the first application is ported;
the script writing module is used for: compiling a Shell script; the Shell script is used for calling an inlet of a first application program by adopting a container so as to enable the first application program to run in the container;
the compressed file module is used for: the Shell script, the container, and the first application are packaged as a compressed file running on the second host.
Further, in an optional embodiment, the apparatus further comprises an operation module;
the operation module is used for: after the Shell script, the container and the first application program are packaged into a compressed file running on the second host by the compressed file module, when an instruction for running the first application program on the second host is received through the container, the container calls an inlet of the first application program so that the first application program runs in the container.
Further, in an alternative embodiment, the container packaging module is configured to: the Python environment is packaged into a container in the format of an executable program.
Further, in an alternative embodiment, the apparatus may further comprise other program execution modules,
the other program execution modules are for: after the Shell script, the container and the first application program are packaged into a compressed file running on the second host by the compressed file module, the container calls the entries of other application programs except the first application program according to the received instructions for running the other application programs so as to be used as a Python environment on the second host to run the other application programs.
Further, in an alternative embodiment, the container is in the same level directory as the first application.
The embodiment of the invention has the advantages that the first application program can normally run in the Python environment through the process of developing the first application program and developing the Python environment; by editing the Shell script, the first application program runs in a Python environment provided by the container, so that the first application program does not interact with the environment of the second host computer, and runs in the Python environment matched with the application program when the first application program is developed; the Shell script, the container and the first application program are packaged into a compressed file, so that the Shell script, the container and the first application program are still located together when being transplanted to a second host, and respective tasks are respectively executed, and the purpose that the first application program still normally runs in a Python environment after being transplanted to the second host is achieved.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
The accompanying drawings are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the example serve to explain the principles of the invention and not to limit the invention.
Fig. 1 is a flowchart of a method for running an application according to an embodiment of the present invention;
fig. 2 is a block diagram of an apparatus for running an application according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
The steps illustrated in the flow charts of the figures may be performed in a computer system such as a set of computer-executable instructions. Also, while a logical order is shown in the flow diagrams, in some cases, the steps shown or described may be performed in an order different than here.
In one aspect, an embodiment of the present invention provides a method for running an application, as shown in fig. 1, the method includes steps S101 to S105.
Step S101, packaging a Python environment developed when a first application program is developed on a first host computer into a container; wherein the container runs independently on the second host to which the first application is ported.
The first application program is developed on the first host, and the Python environment needs to be used and debugged when the first application system is developed on the first host. Through the process of developing the first application and developing the Python environment, the first application can be enabled to run normally in the Python environment. However, the first application may not be able to run normally on the other host (e.g., the second host) because the Python environment may not be installed in the operating system installed on the other host, or the Python environment may not be compatible in version inconsistency, or the dependent library file or dependent package may not be installed. When the first application cannot normally run on other hosts, a developer writes a third-party dependency package into a configuration file, and installs the dependency package when installing the application. However, this method depends on the environment local to the host, so this method still has great limitation, and sometimes the third party dependent package cannot be successfully installed in the operating system due to network delay and other problems when being downloaded.
In the method provided in the embodiment of the present invention, a Python environment developed when a first application is developed on a first host is packaged as a container, where the container receives an instruction from a second host on one hand, and calls an entry of the application on the other hand, that is, when the second host sends an instruction to the application, the instruction is received by the container, and the container calls an interface of the application, so that the first application runs in the Python environment provided by the container, and therefore, there is no interaction between the first application and the environment of the second host, but runs in the Python environment cooperating with the application when the first application is developed, and the application can still run normally in the Python environment.
Step S103, compiling Shell scripts; the Shell script is used for calling an inlet of the first application program by using the container so as to enable the first application program to run in the container.
In order to achieve the above purpose that the first application program still normally runs in the Python environment after being migrated to the second host, the Shell script is written in step S103. Shell is basically a command interpreter that receives user commands and then invokes the corresponding application. To achieve the above object, the Shell script is configured to: and when the first application program runs in the second host, calling the inlet of the first application program by using the container so as to enable the first application program to run in the container. Whereby the above-mentioned object can be achieved.
Step S105, packaging the Shell script, the container, and the first application as a compressed file running on the second host.
In order to achieve the above-mentioned purpose of enabling the first application program to normally run in the Python environment after being transplanted to the second host, the Shell script, the container and the first application program are all absent and unavailable, so that the Shell script, the container and the first application program need to be always located together.
The embodiment of the invention has the advantages that the first application program can normally run in the Python environment through the process of developing the first application program and developing the Python environment; by editing the Shell script, the first application program runs in a Python environment provided by the container, so that the first application program does not interact with the environment of the second host computer, and runs in the Python environment matched with the application program when the first application program is developed; the Shell script, the container and the first application program are packaged into a compressed file, so that the Shell script, the container and the first application program are still located together when being transplanted to a second host, and respective tasks are respectively executed, and the purpose that the first application program still normally runs in a Python environment after being transplanted to the second host is achieved.
Further, in an optional embodiment, after step S105, the method further includes:
when an instruction to run the first application on the second host is received through the container, the container calls an entry of the first application to cause the first application to run in the container.
In this alternative embodiment, the container may call an entry of the first application program, so that the first application program runs in the container, and thus the first application program does not interact with the environment of the second host computer, but runs in a Python environment cooperating with the application program when the first application program is developed, so that the application program may still run normally in this Python environment.
Further, in an optional embodiment, step S103 includes:
the Python environment is packaged into a container in the format of an executable program.
In this alternative embodiment, the Python environment may be packaged into an executable program format that may be executed in the Windows operating system on the second host.
Further, in an optional embodiment, after step S105, the method further includes:
and calling the entrances of other application programs except the first application program by the container according to the received instructions for running other application programs so as to run other application programs as a Python environment on the second host.
In this alternative embodiment, the container no longer executes only the first application, but may be used as the only Python environment of the second host to run other applications in the second host that need to run using the Python environment in the case that, for example, no Python environment is installed in the operating system of the second host, which may improve the efficiency of executing the application on the second host.
Further, in an alternative embodiment, the container is in the same level directory as the first application.
For example, the container and the first application may be in a root directory of the compressed file. This would facilitate editing the path when calling the file when editing the Shell script.
In another aspect, an embodiment of the present invention provides an apparatus for running an application, as shown in fig. 2, the apparatus includes a container packaging module 201, a script writing module 203, and a compressed file module 205.
The container packaging module 201 is used for: packaging a Python environment developed when a first application program is developed on a first host computer into a container; wherein the container runs independently on a second host to which the first application is ported;
the script writing module 203 is configured to: compiling a Shell script; the Shell script is used for calling an inlet of a first application program by adopting a container so as to enable the first application program to run in the container;
the compressed file module 205 is configured to: the Shell script, the container, and the first application are packaged as a compressed file running on the second host.
The embodiment of the invention has the advantages that the first application program can normally run in the Python environment through the process of developing the first application program and developing the Python environment; by editing the Shell script, the first application program runs in a Python environment provided by the container, so that the first application program does not interact with the environment of the second host computer, and runs in the Python environment matched with the application program when the first application program is developed; the Shell script, the container and the first application program are packaged into a compressed file, so that the Shell script, the container and the first application program are still located together when being transplanted to a second host, and respective tasks are respectively executed, and the purpose that the first application program still normally runs in a Python environment after being transplanted to the second host is achieved.
Further, in an optional embodiment, the apparatus further comprises an operation module.
The operation module is used for: after the compressed file module 205 encapsulates the Shell script, the container, and the first application as a compressed file running on the second host, when an instruction to run the first application on the second host is received through the container, the container is caused to call an entry of the first application so that the first application runs in the container.
Further, in an alternative embodiment, the container packaging module 201 is configured to: the Python environment is packaged into a container in the format of an executable program.
Further, in an optional embodiment, the apparatus further comprises other program execution modules.
The other program execution modules are for: after the compressed file module 205 encapsulates the Shell script, the container, and the first application as a compressed file running on the second host, the container is enabled to call the entries of other applications besides the first application according to the received instructions to run the other applications to serve as a Python environment on the second host to run the other applications.
Further, in an alternative embodiment, the container is in the same level directory as the first application.
Although the embodiments of the present invention have been described above, the above description is only for the convenience of understanding the present invention, and is not intended to limit the present invention. It will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (6)

1. A method for running an application, the method comprising the steps of:
packaging a Python environment developed when a first application program is developed on a first host computer into a container; wherein the container runs independently on a second host to which the first application is ported;
compiling a Shell script; the Shell script is used for calling an inlet of the first application program by adopting the container so as to enable the first application program to run in the container;
packaging the Shell script, the container and the first application program into a compressed file running on the second host;
after the step of packaging the Shell script, the container, and the first application as a compressed file running on the second host, the method further comprises:
when an instruction to run the first application program on the second host is received through the container, calling an entry of the first application program by the container so as to cause the first application program to run in the container;
calling, by the container, an entry of another application other than the first application according to the received instruction to run the another application as a Python environment on the second host.
2. The method of claim 1, wherein the step of packaging a Python environment developed at the time of developing the first application on the first host as a container comprises:
encapsulating the Python environment into the container in an executable program format.
3. The method of claim 1, wherein the container is in a same level directory as the first application.
4. An apparatus for running an application, the apparatus comprising a container packaging module, a script writing module, a compressed file module, a running module, and other program execution modules; wherein the content of the first and second substances,
the container packaging module is configured to: packaging a Python environment developed when a first application program is developed on a first host computer into a container; wherein the container runs independently on a second host to which the first application is ported;
the script writing module is used for: compiling a Shell script; the Shell script is used for calling an inlet of the first application program by adopting the container so as to enable the first application program to run in the container;
the compressed file module is used for: packaging the Shell script, the container and the first application program into a compressed file running on the second host;
the operation module is used for: after the Shell script, the container and the first application program are packaged into a compressed file running on the second host by the compressed file module, when an instruction for running the first application program on the second host is received through the container, the container calls an inlet of the first application program so as to run the first application program in the container;
the other program execution module is configured to: after the Shell script, the container and the first application program are packaged into a compressed file running on the second host by the compressed file module, the container calls the entries of other application programs except the first application program according to the received instruction for running other application programs so as to be used as a Python environment on the second host to run the other application programs.
5. The apparatus of claim 4, wherein the container encapsulation module is to: encapsulating the Python environment into the container in an executable program format.
6. The apparatus of claim 4, wherein the container is in a same level directory as the first application.
CN201811142996.4A 2018-09-28 2018-09-28 Method and device for running application program Active CN109284112B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811142996.4A CN109284112B (en) 2018-09-28 2018-09-28 Method and device for running application program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811142996.4A CN109284112B (en) 2018-09-28 2018-09-28 Method and device for running application program

Publications (2)

Publication Number Publication Date
CN109284112A CN109284112A (en) 2019-01-29
CN109284112B true CN109284112B (en) 2022-03-22

Family

ID=65182465

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811142996.4A Active CN109284112B (en) 2018-09-28 2018-09-28 Method and device for running application program

Country Status (1)

Country Link
CN (1) CN109284112B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112486512A (en) * 2020-11-25 2021-03-12 湖南麒麟信安科技股份有限公司 Linux general software adaptation method and system based on container and stacked file system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8336025B1 (en) * 2007-02-08 2012-12-18 The Mathworks, Inc. Pattern modeling methods and systems
CN103713902A (en) * 2013-12-26 2014-04-09 Tcl集团股份有限公司 Method and system for BOA compiling based on Android system
CN106406960A (en) * 2016-09-28 2017-02-15 郑州云海信息技术有限公司 Method for deploying software quickly in linux environment
CN106959913A (en) * 2017-03-09 2017-07-18 龙尚科技(上海)有限公司 A kind of mode that power-on and power-off pressure test is realized based on Python environment
CN107066265A (en) * 2017-03-15 2017-08-18 杭州华澜微电子股份有限公司 The interconnecting method and system of different programming languages
CN107577937A (en) * 2017-09-01 2018-01-12 深信服科技股份有限公司 A kind of application program guard method and system

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7209921B2 (en) * 2000-09-01 2007-04-24 Op40, Inc. Method and system for deploying an asset over a multi-tiered network
CN106020921B (en) * 2016-05-16 2019-03-29 广东天波信息技术股份有限公司 The transplantation method and its system of peripheral hardware application program
CN107894886B (en) * 2017-11-23 2019-02-19 北京九章云极科技有限公司 A kind of method, apparatus and terminal device running code

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8336025B1 (en) * 2007-02-08 2012-12-18 The Mathworks, Inc. Pattern modeling methods and systems
CN103713902A (en) * 2013-12-26 2014-04-09 Tcl集团股份有限公司 Method and system for BOA compiling based on Android system
CN106406960A (en) * 2016-09-28 2017-02-15 郑州云海信息技术有限公司 Method for deploying software quickly in linux environment
CN106959913A (en) * 2017-03-09 2017-07-18 龙尚科技(上海)有限公司 A kind of mode that power-on and power-off pressure test is realized based on Python environment
CN107066265A (en) * 2017-03-15 2017-08-18 杭州华澜微电子股份有限公司 The interconnecting method and system of different programming languages
CN107577937A (en) * 2017-09-01 2018-01-12 深信服科技股份有限公司 A kind of application program guard method and system

Also Published As

Publication number Publication date
CN109284112A (en) 2019-01-29

Similar Documents

Publication Publication Date Title
CN111176626B (en) Cross-programming-language code calling method and device, medium and equipment
CN107092488B (en) Method and system for realizing non-invasive point burying of application
CN102622211A (en) Method for application development and device
US9489182B1 (en) Transparent process interception
US20210124822A1 (en) Function execution based on data locality and securing integration flows
US8549506B2 (en) Resumable methods
US20050086640A1 (en) Initiating execution of application programs on a data processing arrangement
CN109670299A (en) A kind of method and electronic equipment creating Python sandbox environment
CN106372250A (en) Parameter passing method and device capable of starting local application through URL protocol
CN102622263B (en) Method for implementing embedded system based virtual machine on set-top box
CN110659031A (en) Compiling method and device of application program, electronic equipment and storage medium
CN112235357A (en) Cross-platform application development system
US11650810B1 (en) Annotation based automated containerization
CN111176629A (en) Application development method and device
CN111740948A (en) Data packet issuing method, dynamic updating method, device, equipment and medium
CN114579194B (en) Exception handling method and system based on Spring remote call
CN109284112B (en) Method and device for running application program
CN108153533B (en) Method and device for making installation program, and method and device for installing program
CN103530165B (en) A kind of java solution that is applied to Internet of Things industry
CN106775916B (en) Method and device for reducing application installation packages and electronic equipment
CN113127329B (en) Script debugging method and device and computer storage medium
CN114490103A (en) Operating system interface calling method and device and electronic equipment
WO2024011825A1 (en) System, method and apparatus for introducing applet into third-party app, and medium
CN104133669B (en) A kind of control method and terminal device of desktop application
WO2022184112A1 (en) Android system application debugging method and apparatus, program, medium, and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant