Code publishing method, device, computer equipment and readable storage medium

By obtaining and publishing the running associated code and its execution files of Python code, the program crash problem caused by environment configuration in traditional code release is solved, the stability and repairability of the code is achieved, and the efficiency of code deployment is improved. Convenience.

CN118535458BActive Publication Date: 2025-02-18CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410550123.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-06
Publication Date
2025-02-18
Estimated Expiration
2044-05-06

AI Technical Summary

Technical Problem

In traditional Python code release methods, users may crash the program due to improper environment configuration when running business scripts, and cannot be repaired, resulting in difficulty in packaging and publishing the code.

Method used

Provide a code publishing method, obtain business source code written in Python and its running associated code, including target entry code and target repair code, and obtain execution files based on the code running environment, and publish processing to ensure the stability and ability of the code. Repairability.

Benefits of technology

By obtaining the execution files running associated code on the code deployment device, ensuring that it has a running dependency environment, and adding target entry code and target repair code to the release version, it solves the problem of program operation errors and provides flexibility in program repair , improves the efficiency and convenience of code deployment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535458B_ABST
    Figure CN118535458B_ABST
Patent Text Reader

Abstract

The present application relates to the field of computer and software technology, and in particular to a code publishing method, apparatus, computer equipment and readable storage medium. Obtain a business source code written in a first programming language and a running-related code corresponding to the business source code, as well as a code running environment corresponding to the first programming language; wherein the running-related code includes a target entry code and a target repair code; based on the code running environment, obtain an execution file corresponding to the running-related code; wherein the execution file includes instructions for driving the execution of the running-related code; and publish the business source code, the running-related code, the code running environment and the execution file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer and software technology, and in particular to a code publishing method, apparatus, computer device and readable storage medium. Background Art

[0002] In all aspects of Python development, code release is a key step, which ensures the portability and reusability of the code.

[0003] The traditional release method is: the developer writes and debugs the business script and then delivers the script directly to the user. The user has a Python runtime environment locally and installs or updates the dependencies based on the script's library dependencies. The user then runs the script for testing.

[0004] However, due to factors such as improper environment configuration, the program may crash when users run business scripts. The program crashes and cannot be repaired, which makes it difficult to package and release the code, so improvement is urgently needed. Summary of the invention

[0005] Based on this, it is necessary to provide a code publishing method, device, computer equipment and readable storage medium that can repair the program in response to the above technical problems.

[0006] In a first aspect, the present application provides a code publishing method, comprising:

[0007] Acquire a business source code written in a first programming language and an operation-related code corresponding to the business source code, and a code operation environment corresponding to the first programming language; wherein the operation-related code includes a target entry code and a target repair code;

[0008] Based on the code running environment, obtaining an execution file corresponding to the running associated code; wherein the execution file includes instructions for driving the execution of the running associated code;

[0009] Publish business source code, operation-related code, code operation environment and execution files.

[0010] In one embodiment, obtaining the operation-related code corresponding to the business source code includes:

[0011] Obtaining an initial associated code corresponding to a business source code; wherein the initial associated code includes an initial entry code and an initial repair code;

[0012] The initial associated code is encrypted to obtain the running associated code corresponding to the business source code.

[0013] In one embodiment, encrypting the initial association code includes:

[0014] The target encryption level is obtained, and the initial association code is encrypted using an encryption strategy corresponding to the target encryption level.

[0015] In one of the embodiments, the initial association code is encrypted, including at least one of the following:

[0016] Replace all strings in the initial association code with unreadable random strings;

[0017] Using a set compression format, the initial associated code is compressed;

[0018] The initial association code is encrypted using a set encryption algorithm;

[0019] The initial associated code is encoded using a set encoding format;

[0020] Convert each character in the initial associated code to a numeric value in the set base.

[0021] In one embodiment, obtaining an execution file corresponding to running the associated code based on the code running environment includes:

[0022] In the code running environment, the associated code is run based on the execution instruction, and when the code running result is successful, the corresponding execution instruction is written into the initial file to obtain the execution file corresponding to the associated code.

[0023] In one embodiment, publishing the service source code, the operation-related code, the code operation environment and the execution file includes:

[0024] Packing the instructions corresponding to the target entry code in the executable file into an executable program; wherein the executable program is used to run the executable file;

[0025] Publish business source code, operation-related code, code operation environment, execution files and executable programs.

[0026] In one embodiment, obtaining a service source code written in a first programming language includes:

[0027] Obtaining a business interface code written in a second programming language and a business logic code written in a first programming language;

[0028] Performing language conversion processing on the business interface code to obtain the business interface code written in the first programming language;

[0029] The business interface code and business logic code written in the first programming language are used as business source code.

[0030] In a second aspect, the present application also provides a code publishing device, including:

[0031] An acquisition module, used to acquire a business source code written in a first programming language and an operation-related code corresponding to the business source code, and a code operation environment corresponding to the first programming language; wherein the operation-related code includes a target entry code and a target repair code;

[0032] A file generation module, used to obtain an execution file corresponding to the running associated code based on the code running environment; wherein the execution file includes instructions for driving the execution of the running associated code;

[0033] The publishing module is used to publish business source code, operation-related code, code running environment and execution files.

[0034] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0035] Acquire a business source code written in a first programming language and an operation-related code corresponding to the business source code, and a code operation environment corresponding to the first programming language; wherein the operation-related code includes a target entry code and a target repair code;

[0036] Based on the code running environment, obtaining an execution file corresponding to the running associated code; wherein the execution file includes instructions for driving the execution of the running associated code;

[0037] Publish business source code, operation-related code, code operation environment and execution files.

[0038] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the following steps are implemented:

[0039] Acquire a business source code written in a first programming language and an operation-related code corresponding to the business source code, and a code operation environment corresponding to the first programming language; wherein the operation-related code includes a target entry code and a target repair code;

[0040] Based on the code running environment, obtaining an execution file corresponding to the running associated code; wherein the execution file includes instructions for driving the execution of the running associated code;

[0041] Publish business source code, operation-related code, code operation environment and execution files.

[0042] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0043] Acquire a business source code written in a first programming language and an operation-related code corresponding to the business source code, and a code operation environment corresponding to the first programming language; wherein the operation-related code includes a target entry code and a target repair code;

[0044] Based on the code running environment, obtaining an execution file corresponding to the running associated code; wherein the execution file includes instructions for driving the execution of the running associated code;

[0045] Publish business source code, operation-related code, code operation environment and execution files.

[0046] The above code publishing method, device, computer equipment and readable storage medium obtain the execution file corresponding to the running associated code based on the code running environment, ensuring that the running associated code can have the corresponding running dependent environment on the code deployment device; further, the target entry code and target repair code are added to the release version to call and repair the business source code, solving the problem of program running errors in traditional technologies; in addition, the execution file is not only used by the program during normal operation, but can also be called by the user when the program needs to be repaired. This flexibility makes the code deployment process more efficient and convenient, because the user can selectively perform repair operations according to actual conditions without waiting for the development team to release a new version. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0048] FIG1 is a schematic diagram of a flow chart of a code publishing method in one embodiment;

[0049] FIG2 is a flow chart of steps for obtaining and running associated codes in one embodiment;

[0050] FIG3 is a schematic diagram of a flow chart of a code publishing method in another embodiment;

[0051] FIG4 is a schematic diagram of a process for obtaining a service source code in another embodiment;

[0052] FIG5 is a block diagram of a code issuing device in one embodiment;

[0053] FIG. 6 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0055] In an exemplary embodiment, as shown in FIG1 , a code publishing method is provided, taking the method applied to a computer device as an example, the method includes the following steps 102 to 103. Among them:

[0056] Step S101: Acquire a business source code written in a first programming language, an operation-related code corresponding to the business source code, and a code operation environment corresponding to the first programming language.

[0057] The first programming language may be Java, Python, C#, etc. The business source code written in the first programming language refers to the program code written in the first programming language to implement business logic and functions. These source codes are the core of software development, and they define how the program should respond to input, process data, interact with external systems, and provide user interfaces.

[0058] For example, in Python development, business source code usually refers to Python scripts used to execute specific business logic or tasks. These scripts may involve data processing, file operations, network communications, automated tasks, etc.

[0059] Among them, the operation-related code is an auxiliary code that works with the business source code, which may include initialization programs, configuration files, dependency injection, error handling, and other non-business logic related codes. Optionally, the operation-related code in this embodiment includes target entry code and target repair code; the target entry code is usually the starting point of the program, such as the main function or method, which is responsible for starting the application and calling the business logic. The target repair code can be a patch for a known problem or vulnerability, which is used to fix or bypass certain problems at runtime to ensure the stability and security of the program.

[0060] The code running environment of the first programming language refers to software or a system that can interpret or execute the code of a specific programming language. For example, if the business source code is written in Python, then a Python interpreter needs to be installed; if it is Java, then a Java Runtime Environment (JRE) or a Java Development Kit (JDK) is required.

[0061] Step S102: based on the code running environment, obtaining the execution file corresponding to the running associated code.

[0062] The executable file includes instructions for driving the execution of the associated code. An executable file can be an executable program, script, batch file, or other type of file that contains the specific instructions required to start and run an application. These instructions may involve loading configuration files, setting environment variables, calling specific functions or methods, and performing other necessary initialization or startup tasks.

[0063] Exemplarily, an execution file may include the following instructions: 1) Startup instructions: commands used to initialize an application or service, which may include loading a configuration file, setting an environment variable, or calling a specific startup script. 2) Call instructions: directly point to the run-related code that needs to be executed, such as the target entry code and the target repair code, to ensure that they can be called and executed correctly. 3) Parameter setting: provide the necessary command line parameters or configuration options for the run-related code. 4) Dependency loading: ensure that all necessary libraries and dependencies are loaded correctly so that the run-related code can be executed smoothly. 5) Error handling and logging: when an error is encountered during execution, the execution file should contain the corresponding error handling instructions and record the necessary log information for subsequent analysis.

[0064] Specifically, the developer needs to create or obtain these executable files according to the specific code running environment and application requirements. This may involve manually writing scripts, using build tools to automatically generate scripts, or obtaining pre-written executable files from a version control system.

[0065] For example, the developer can use a text editor (such as Notepad++, Sublime Text, VS Code, etc.) to create a new text file (executable file) and save it with a .bat extension. The .bat file contains a series of batch commands to execute the associated code; or after obtaining the executable file, save and run the executable file (.bat file) to ensure that it correctly starts the associated code.

[0066] Step S103, publishing the business source code, operation-related code, code operation environment and execution file.

[0067] Specifically, package the business source code, running-related code, necessary libraries and dependencies, and configuration files into one or more files. The packaging format may vary depending on the project and technology stack, such as JAR files (Java), WAR files (Web applications), ZIP files, Docker images, etc. Secondly, assign a version number to the packaged file to facilitate tracking and management of different versions of the software. Then, distribute the packaged files and related documents to the predetermined release channels, such as internal servers, app stores, Docker repositories, etc. According to the deployment plan and strategy, deploy the new version of the software to the production environment or test environment. This may involve automated deployment scripts or manual installation steps.

[0068] The above code publishing method obtains the execution file corresponding to the running associated code based on the code running environment, ensuring that the running associated code can have the corresponding running dependent environment on the code deployment device; further, the target entry code and target repair code are added to the release version to call and repair the business source code, solving the problem of program running errors in traditional technologies; in addition, the execution file is not only used by the program during normal operation, but can also be called by the user when the program needs to be repaired. This flexibility makes the code deployment process more efficient and convenient, because the user can selectively perform repair operations according to the actual situation without waiting for the development team to release a new version.

[0069] In an exemplary embodiment, as shown in FIG2 , obtaining the operation-related code corresponding to the service source code includes steps 201 to 202. Among them:

[0070] S201, obtaining an initial association code corresponding to a business source code.

[0071] The initial associated code includes the initial entry code and the initial repair code. The initial entry code is the code segment required to start and run the business source code, usually including the main entry point of the program, such as the main function or other initialization program. The initial repair code contains logic for handling potential errors or abnormal situations, which may include fixes or emergency measures for known problems.

[0072] Alternatively, obtaining these initial associated codes may involve retrieving them from a source code repository, receiving them from the developer, or extracting them via automated tools.

[0073] S202, encrypt the initial associated code to obtain the running associated code corresponding to the business source code.

[0074] It is understood that after obtaining the initial association code, the next step is to encrypt it to add a layer of security. The encryption process can use an encryption algorithm, which depends on the security requirements and available resources.

[0075] In one implementable manner, encrypting the initial association code includes: obtaining a target encryption level, and using an encryption strategy corresponding to the target encryption level to encrypt the initial association code.

[0076] It is understandable that different encryption levels may correspond to different encryption algorithms, key lengths, and encryption strengths. Based on the target encryption level, select the corresponding encryption strategy. This may include selecting a specific encryption algorithm (such as a symmetric encryption algorithm, an asymmetric encryption algorithm, etc.), determining the key length and management method, and defining the specific encryption and decryption process, using the encryption strategy corresponding to the target encryption level, and encrypting the initial association code.

[0077] In another possible implementation, the initial association code is encrypted, including at least one of the following:

[0078] Method 1) Replace the original variable names, method names, and class names in the initial associated code with unreadable random strings;

[0079] It is understood that obfuscation tools are used to generate a series of random, meaningless strings that will be used to replace identifiers in the source code.

[0080] Method 2) Replace all strings in the initial association code with unreadable random strings;

[0081] It is understandable that the obfuscation tool is used to scan the source code to identify all string literals, which may be used for various purposes, such as user prompts, error messages, configuration file paths, etc. The obfuscation tool is used to replace all string literals identified in the source code with the random strings generated above.

[0082] Method 3) Using a set compression format to compress the initial associated code;

[0083] It is understandable that common compression algorithms include Gzip, Deflate, Brotli, etc. These algorithms reduce file size by identifying and eliminating redundant information in the code.

[0084] Method 4) Encrypt the initial association code using a set encryption algorithm;

[0085] It is understood that the keys used for encryption and decryption are generated according to the selected encryption algorithm. For symmetric encryption algorithms (such as AES, DES), the same key is used for encryption and decryption; while for asymmetric encryption algorithms (such as RSA), public key encryption and private key decryption are used.

[0086] Method 5) using a set encoding format to encode the initial association code;

[0087] It is understood that the initial associated code is converted into an encoded string using the selected encoding format. For example, if Base64 encoding is used, the original code is converted into a string of characters consisting of AZ, az, 0-9, + and / .

[0088] Method 6) Convert each character in the initial association code into a numerical value of a set base.

[0089] It is understood that the character is to be converted to a target base number, such as binary, octal, decimal or hexadecimal. Each character in the initial associated code is traversed and each character is converted to a corresponding numerical value according to its ASCII code (or other character encoding standards, such as UTF-8). For example, in ASCII, the numerical value corresponding to the character 'A' is 65.

[0090] Exemplarily, the above-mentioned methods 1) to 6) are combined to obtain the following six encryption levels:

[0091] A) Level 1: Replace the original variable names, method names, and class names with unreadable random strings;

[0092] B) Level 2: contains level 1 and replaces all strings in the code with unreadable random strings;

[0093] C) level3: includes level2 and compresses the code using the GZIP library;

[0094] D) Level 4: includes level 3 and will use XOR algorithm and password to encrypt the code;

[0095] E) level5: contains level4 and encodes the code using base64.b85encode;

[0096] F) Level 6: includes level 5 and converts the code into hexadecimal representation.

[0097] It can be understood that the initial associated code (.py file) is encrypted according to the obtained encryption level level. The encryption level is divided according to the code execution efficiency and encryption depth. The levels are from low to high. The higher the level, the lower the code execution efficiency and the higher the encryption depth, and the more difficult it is to decrypt.

[0098] Furthermore, obtaining the business source code includes: obtaining an initial source code; and encrypting the initial source code to obtain the business source code.

[0099] In this embodiment, the initial source code is encrypted in the same manner as the above-mentioned encryption of the initial operation-related code.

[0100] Furthermore, the encrypted initial associated code is compiled to obtain the running associated code corresponding to the business source code.

[0101] Specifically, you can use either of the following two compilation methods:

[0102] a) Method 1: Compile the .py code (encrypted initial associated code and initial source code) into a binary file through Cython.Build.cythonize, and the output format is .pyd;

[0103] Among them, Cython.Build.cythonize is a function provided by Cython, which is used to convert Python or Cython source code files (.pyx or .py) into C code that can be compiled by a C compiler. This process is usually to improve the execution efficiency of the code, because C code generally runs much faster than pure Python code.

[0104] b) Method 2: Use the compileall library to compile the .py code (encrypted initial associated code and initial source code) into a binary file, with the output format being .pyc;

[0105] Among them, compileall is a standard library module of Python, which provides tools to compile all Python source files in a directory. The compiled files will have a .pyc extension, which is the bytecode file compiled by Python. However, compileall does not directly compile the source code into machine code or binary files, but compiles it into Python bytecode, which can still be executed by the Python interpreter.

[0106] In this embodiment, after the above encryption and compilation steps, the business source code written in the first programming language and the operation-associated code corresponding to the business source code are stored in the initial project directory; accordingly, when obtaining the business source code written in the first programming language and the operation-associated code corresponding to the business source code, in the initial project directory, use os.walk to traverse the file (including all compiled .py files), and use the os.path.join function and shutil.copy function to copy the above .pyd or .pyc file to the library file directory site-packages\[project module name] in the prepared code execution environment. The above process is to move the compiled business source code and the operation-associated code corresponding to the business source code to the code execution environment.

[0107] Among them, the os.path.join function is used to splice multiple path components into a complete path. This function automatically handles the path separator so that the correct path can be generated on different operating systems. The shutil.copy function is used to copy files. You can use it to copy a file from the source path to the target path.

[0108] The site-packages directory is where third-party libraries and extension modules are installed. Specifically, under the site-packages directory, create a directory with the same name as the project module. For example, if your project module is called my_project, you should create a directory called my_project under site-packages. Copy the compiled .pyc or .pyd file to the newly created my_project directory. Make sure the directory structure of the file matches the source code directory structure so that the module can be imported correctly. Then, start the Python interpreter and try to import your project module to make sure everything works properly.

[0109] In this embodiment, the security of code transmission is improved through encryption.

[0110] In an exemplary embodiment, based on the code running environment, obtaining the execution file corresponding to the running associated code includes: in the code running environment, running the running associated code based on the execution instruction, and when the code running result is successful, writing the corresponding execution instruction to the initial file to obtain the execution file corresponding to the running associated code.

[0111] Specifically, you first need to configure and prepare the code execution environment, which may include installing necessary software libraries, setting environment variables, configuring the network, etc., to ensure that the execution-related code can be successfully executed in the environment. In the prepared code execution environment, use specific execution instructions to run the execution-related code. This may involve calling a command line tool, a script, or a run function in an integrated development environment (IDE).

[0112] Furthermore, after running the run-associated code, its run results need to be checked. If the code is successfully executed without generating errors or exceptions, then the run result can be considered successful. Write execution instructions: Once the run-associated code is confirmed to have been successfully executed, the execution instructions for running the code will be written into an initial file. This initial file may be an empty file or contain some basic framework code. Generate execution file: After writing the execution instructions, the initial file becomes an execution file containing the necessary instructions. This file can now be used to automatically execute the run-associated code in future run environments without having to manually enter the execution instructions.

[0113] Exemplarily, in the code running environment, obtaining the execution file corresponding to the running associated code includes the following steps:

[0114] Step 1) Get the initial entry code main.py written by the developer (converted to main.pyc or main.pyd through the above stages);

[0115] Step 2) Get the executable file written by the developer (including the bat sub-file for executing the entry code), and run main.pyc or main.pyd under site-packages\[project module name] through the python.exe path of the code running environment obtained above;

[0116] Step 3) Get the initial repair code repair.py written by the developer (converted to repair.pyc or repair.pyd through the above stages);

[0117] Step 4) Obtain the executable file written by the developer (including the repair bat subfile for executing the repair code), and run repair.pyc or repair.pyd under site-packages\[project module name] through the python.exe path of the code running environment obtained above.

[0118] It is understandable that in the traditional publishing process, the developer directly delivers the script to the user after writing and debugging it. The user has a local Python operating environment and installs or updates the dependencies according to the script's library dependencies. The user then runs the script for testing. However, the above script does not have a graphical interface for interaction, and the user needs to have the ability to run the script. Therefore, in this embodiment, the main() method in the above step 1) creates QApplication and QMainWindow as necessary objects for starting the graphical interface; QApplication and QMainWindow are key components when creating a graphical user interface (GUI) application.

[0119] Specifically, as shown in FIG3 , obtaining a service source code written in a first programming language includes:

[0120] Step 301, obtaining a business interface code written in a second programming language and a business logic code written in a first programming language.

[0121] The second programming language may be a UI design language, specifically a front-end design language such as HTML, CSS, JSX, etc. The business interface code written based on the second programming language may be a UI file.

[0122] Step 302: perform language conversion processing on the business interface code to obtain the business interface code written in the first programming language.

[0123] Specifically, when converting .ui files (usually created by Qt Designer) to .py format, you can use the pyuic tool, which is a utility included with PyQt or PySide.

[0124] Step 303: Use the business interface code and business logic code written in the first programming language as business source code.

[0125] Specifically, the converted UI file (business interface code based on the business interface code written in the first programming language) and the business logic code (py file) are combined to obtain the business source code.

[0126] In an exemplary embodiment, the business source code, operation-related code, code operation environment and execution file are released, including: packaging the instructions corresponding to the target entry code in the execution file into an executable program; and releasing the business source code, operation-related code, code operation environment, execution file and executable program.

[0127] Among them, the executable program is used to run the executable file.

[0128] Specifically, the previously generated executable files are packaged into an independent executable program. This executable program is usually specific to the operating system and can be run directly on the target operating system, such as an .exe file. The packaging process may involve packaging the executable file with the necessary runtime libraries, dependencies, and other resources to ensure that the executable program can run independently on the target system without the need to install other components.

[0129] It is understandable that the packaged executable program is a file that the end user can run directly. Users do not need to care about the internal source code or complex operating environment settings. They only need to double-click the executable program (or run it in the command line) to start and execute the previously packaged operating-related code. This method greatly simplifies the user's operation process, lowers the technical threshold for running the program, and also improves the convenience of program distribution and use.

[0130] Next, the business source code, running-related code (which may be an encrypted version), code running environment description, execution files (which may be pre-packaging versions for advanced users or users who need a customized execution environment), and the newly packaged executable program are released as a whole. The release process may include uploading these files to a version control system, build system, or distribution platform so that users or deployment teams can easily obtain and use them. In addition, the release process may also include generating documents such as release notes, change logs, and version information to help users understand the content and important updates of this release.

[0131] In this embodiment, by packaging the executable file into an executable program and performing a unified publishing process on all related components, it can be ensured that users can easily obtain, install and run the software.

[0132] In an exemplary embodiment, as shown in FIG4 , this embodiment provides a code publishing method, including the following process:

[0133] 1. The developer writes the business logic code based on the first programming language to obtain the corresponding py script; and writes the development business interface code based on the second programming language to obtain the corresponding ui file;

[0134] 2. Convert the UI file into py format, combine the UI file and py script file, and the business source code;

[0135] 3. Collect the above py format UI files and script file codes into a folder, and process the py code by obfuscation, encryption, compilation, etc.

[0136] 4. Put the obfuscated folder in the previous step into an executable Python environment (code running environment), which has all dependencies installed in advance;

[0137] 5. The developer writes the target entry code and target repair code;

[0138] 6. In the code running environment, the developer writes two bat-format script codes, "Run bat file" and "Repair bat file", to obtain the executable file;

[0139] Among them, the "run bat file" in the execution file is used to execute the target entry code in step 5, and the "repair bat file" in the execution file is used to execute the target repair code.

[0140] 7. Use the Pyinstaller library to package an executable shell program exe;

[0141] The exe is used to execute the "run bat file" in the above execution file.

[0142] 8. Package the exe program, code running environment, executable file, and other dependencies into a zip file through the zipfile36 library for external release.

[0143] Among them, the bat script solves the problem that the exe cannot be opened after it fails to run successfully. Through the above methods, the reliability and compatibility of the scripts delivered by the test developer are improved.

[0144] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0145] Based on the same inventive concept, the embodiment of the present application also provides a code publishing device for implementing the code publishing method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more code publishing device embodiments provided below can refer to the limitations of the code publishing method above, and will not be repeated here.

[0146] In an exemplary embodiment, as shown in FIG5 , a code publishing device 1 is provided, comprising: an acquisition module 11, a file generation module 12 and a publishing module 13; wherein,

[0147] The acquisition module 11 is used to acquire a business source code written in a first programming language and an operation-related code corresponding to the business source code, and a code operation environment corresponding to the first programming language; wherein the operation-related code includes a target entry code and a target repair code;

[0148] A file generation module 12 is used to obtain an execution file corresponding to the running associated code based on the code running environment; wherein the execution file includes instructions for driving the execution of the running associated code;

[0149] The publishing module 13 is used to publish the business source code, operation-related code, code operation environment and execution file.

[0150] In one embodiment, the acquisition module 11 includes:

[0151] The initial code acquisition module 11 is used to acquire the initial associated code corresponding to the business source code; wherein the initial associated code includes an initial entry code and an initial repair code;

[0152] The encryption module is used to encrypt the initial associated code to obtain the running associated code corresponding to the business source code.

[0153] In one of the embodiments, the encryption module is further used to: obtain a target encryption level, and use an encryption strategy corresponding to the target encryption level to encrypt the initial association code.

[0154] In one embodiment, the encryption module is further used to: encrypt the initial association code, including at least one of the following:

[0155] Replace all strings in the initial association code with unreadable random strings;

[0156] Using a set compression format, the initial associated code is compressed;

[0157] The initial association code is encrypted using a set encryption algorithm;

[0158] The initial associated code is encoded using a set encoding format;

[0159] Convert each character in the initial associated code to a numeric value in the set base.

[0160] In one of the embodiments, the file generation module 12 is also used to: in the code running environment, run the associated code based on the execution instruction, and when the code running result is successful, write the corresponding execution instruction to the initial file to obtain the execution file corresponding to the running associated code.

[0161] In one embodiment, the publishing module 13 is used to: package the instructions corresponding to the target entry code in the execution file into an executable program; wherein the executable program is used to run the execution file;

[0162] Publish business source code, operation-related code, code operation environment, execution files and executable programs.

[0163] In one embodiment, the acquisition module 11 is further used to: acquire a business interface code written in the second programming language and a business logic code written in the first programming language;

[0164] Performing language conversion processing on the business interface code to obtain the business interface code written in the first programming language;

[0165] The business interface code and business logic code written in the first programming language are used as business source code.

[0166] Each module in the above-mentioned code publishing device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0167] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG6. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data of the code publishing method. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a code publishing method is implemented.

[0168] Those skilled in the art will understand that the structure shown in FIG. 6 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0169] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0170] Acquire a business source code written in a first programming language and an operation-related code corresponding to the business source code, and a code operation environment corresponding to the first programming language; wherein the operation-related code includes a target entry code and a target repair code;

[0171] Based on the code running environment, obtaining an execution file corresponding to the running associated code; wherein the execution file includes instructions for driving the execution of the running associated code;

[0172] Publish business source code, operation-related code, code operation environment and execution files.

[0173] In one embodiment, when the processor executes the computer program, the following steps are further implemented: obtaining the operation-related code corresponding to the business source code, including:

[0174] Obtaining an initial associated code corresponding to a business source code; wherein the initial associated code includes an initial entry code and an initial repair code;

[0175] The initial associated code is encrypted to obtain the running associated code corresponding to the business source code.

[0176] The encrypting the initial association code includes: obtaining a target encryption level, and using an encryption strategy corresponding to the target encryption level to encrypt the initial association code.

[0177] In one embodiment, when the processor executes the computer program, the processor further implements the following steps: encrypting the initial association code, including at least one of the following:

[0178] Replace all strings in the initial association code with unreadable random strings;

[0179] Using a set compression format, the initial associated code is compressed;

[0180] The initial association code is encrypted using a set encryption algorithm;

[0181] The initial associated code is encoded using a set encoding format;

[0182] Convert each character in the initial associated code to a numeric value in the set base.

[0183] In one embodiment, when executing the computer program, the processor further implements the following steps: based on the code running environment, obtaining an execution file corresponding to the running associated code, including:

[0184] In the code running environment, the associated code is run based on the execution instruction, and when the code running result is successful, the corresponding execution instruction is written into the initial file to obtain the execution file corresponding to the associated code.

[0185] In one embodiment, when the processor executes the computer program, the following steps are further implemented: publishing the service source code, the operation-related code, the code operation environment and the execution file, including:

[0186] Packing the instructions corresponding to the target entry code in the executable file into an executable program; wherein the executable program is used to run the executable file;

[0187] Publish business source code, operation-related code, code operation environment, execution files and executable programs.

[0188] In one embodiment, when the processor executes the computer program, the processor further implements the following steps: obtaining a service source code written in the first programming language, including:

[0189] Obtaining a business interface code written in a second programming language and a business logic code written in a first programming language;

[0190] Performing language conversion processing on the business interface code to obtain the business interface code written in the first programming language;

[0191] The business interface code and business logic code written in the first programming language are used as business source code.

[0192] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0193] Acquire a business source code written in a first programming language and an operation-related code corresponding to the business source code, and a code operation environment corresponding to the first programming language; wherein the operation-related code includes a target entry code and a target repair code;

[0194] Based on the code running environment, obtaining an execution file corresponding to the running associated code; wherein the execution file includes instructions for driving the execution of the running associated code;

[0195] Publish business source code, operation-related code, code operation environment and execution files.

[0196] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: obtaining the operation-related code corresponding to the business source code, including:

[0197] Obtaining an initial associated code corresponding to a business source code; wherein the initial associated code includes an initial entry code and an initial repair code;

[0198] The initial associated code is encrypted to obtain the running associated code corresponding to the business source code.

[0199] The encrypting the initial association code includes: obtaining a target encryption level, and using an encryption strategy corresponding to the target encryption level to encrypt the initial association code.

[0200] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: encrypting the initial association code, including at least one of the following:

[0201] Replace all strings in the initial association code with unreadable random strings;

[0202] Using a set compression format, the initial associated code is compressed;

[0203] The initial association code is encrypted using a set encryption algorithm;

[0204] The initial associated code is encoded using a set encoding format;

[0205] Convert each character in the initial associated code to a numeric value in the set base.

[0206] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: based on the code running environment, obtaining an execution file corresponding to the running associated code, including:

[0207] In the code running environment, the associated code is run based on the execution instruction, and when the code running result is successful, the corresponding execution instruction is written into the initial file to obtain the execution file corresponding to the associated code.

[0208] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: publishing the business source code, the operation-related code, the code operation environment and the execution file, including:

[0209] Packing the instructions corresponding to the target entry code in the executable file into an executable program; wherein the executable program is used to run the executable file;

[0210] Publish business source code, operation-related code, code operation environment, execution files and executable programs.

[0211] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: obtaining a service source code written in the first programming language, including:

[0212] Obtaining a business interface code written in a second programming language and a business logic code written in a first programming language;

[0213] Performing language conversion processing on the business interface code to obtain the business interface code written in the first programming language;

[0214] The business interface code and business logic code written in the first programming language are used as business source code.

[0215] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:

[0216] Acquire a business source code written in a first programming language and an operation-related code corresponding to the business source code, and a code operation environment corresponding to the first programming language; wherein the operation-related code includes a target entry code and a target repair code;

[0217] Based on the code running environment, obtaining an execution file corresponding to the running associated code; wherein the execution file includes instructions for driving the execution of the running associated code;

[0218] Publish business source code, operation-related code, code operation environment and execution files.

[0219] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: obtaining the operation-related code corresponding to the business source code, including:

[0220] Obtaining an initial associated code corresponding to a business source code; wherein the initial associated code includes an initial entry code and an initial repair code;

[0221] The initial associated code is encrypted to obtain the running associated code corresponding to the business source code.

[0222] The encrypting the initial association code includes: obtaining a target encryption level, and using an encryption strategy corresponding to the target encryption level to encrypt the initial association code.

[0223] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: encrypting the initial association code, including at least one of the following:

[0224] Replace all strings in the initial association code with unreadable random strings;

[0225] Using a set compression format, the initial associated code is compressed;

[0226] The initial association code is encrypted using a set encryption algorithm;

[0227] The initial associated code is encoded using a set encoding format;

[0228] Convert each character in the initial associated code to a numeric value in the set base.

[0229] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: based on the code running environment, obtaining an execution file corresponding to the running associated code, including:

[0230] In the code running environment, the associated code is run based on the execution instruction, and when the code running result is successful, the corresponding execution instruction is written into the initial file to obtain the execution file corresponding to the associated code.

[0231] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: publishing the business source code, the operation-related code, the code operation environment and the execution file, including:

[0232] Packing the instructions corresponding to the target entry code in the executable file into an executable program; wherein the executable program is used to run the executable file;

[0233] Publish business source code, operation-related code, code operation environment, execution files and executable programs.

[0234] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: obtaining a service source code written in the first programming language, including:

[0235] Obtaining a business interface code written in a second programming language and a business logic code written in a first programming language;

[0236] Performing language conversion processing on the business interface code to obtain the business interface code written in the first programming language;

[0237] The business interface code and business logic code written in the first programming language are used as business source code.

[0238] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0239] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0240] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0241] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A code publishing method, characterized in that: The method comprises: Acquire a business source code written in a first programming language and an operation-related code corresponding to the business source code, and a code operation environment corresponding to the first programming language; wherein the operation-related code includes a target entry code and a target repair code; In the code running environment, the running-associated code is run based on the execution instruction, and when the code running result is that the running is successful, the corresponding execution instruction is written into the initial file to obtain the execution file corresponding to the running-associated code; wherein the execution file includes instructions for driving the execution of the running-associated code, and the instructions for driving the execution of the running-associated code in the execution file include startup instructions and error handling instructions; the startup instructions are used to initialize the application or service, and the error handling instructions are used to handle errors encountered during the execution of the running-associated code; The business source code, the operation-related code, the code operation environment and the execution file are released.

2. The method according to claim 1, characterized in that Obtaining the operation-related code corresponding to the business source code includes: Obtaining an initial associated code corresponding to the business source code; wherein the initial associated code includes an initial entry code and an initial repair code; The initial association code is encrypted to obtain the operation association code corresponding to the business source code.

3. The method according to claim 2, wherein encrypting the initial association code comprises: A target encryption level is obtained, and the initial association code is encrypted using an encryption strategy corresponding to the target encryption level.

4. The method according to claim 2, characterized in that: The encrypting the initial association code includes at least one of the following: Replacing all strings in the initial association code with unreadable random strings; Using a set compression format to compress the initial association code; Using a set encryption algorithm to encrypt the initial association code; Encoding the initial association code using a set encoding format; Each character in the initial associated code is converted into a numerical value of a set base.

5. The method according to claim 4, characterized in that The publishing process of the business source code, the operation-related code, the code operation environment and the execution file includes: Packing the instructions corresponding to the target entry code in the execution file into an executable program; wherein the executable program is used to run the execution file; The business source code, the operation-related code, the code operation environment, the execution file and the executable program are released.

6. The method according to claim 1, characterized in that The obtaining of the service source code written in the first programming language includes: Obtaining a business interface code written in a second programming language and a business logic code written in a first programming language; Performing language conversion processing on the business interface code to obtain the business interface code written in the first programming language; The business interface code and business logic code written in the first programming language are used as business source code.

7. The method according to claim 1, characterized in that The code execution environment at least includes installing necessary software libraries, setting environment variables and configuring the network.

8. A code issuing device, characterized in that: The device comprises: An acquisition module, used to acquire a business source code written in a first programming language and an operation-related code corresponding to the business source code, and a code operation environment corresponding to the first programming language; wherein the operation-related code includes a target entry code and a target repair code; A file generation module is used to run the operation-related code based on the execution instruction in the code running environment, and write the corresponding execution instruction to the initial file when the code running result is successful, so as to obtain the execution file corresponding to the operation-related code; wherein the execution file includes instructions for driving the execution of the operation-related code; the instructions for driving the execution of the operation-related code in the execution file include startup instructions and error handling instructions; the startup instructions are used to initialize the application or service, and the error handling instructions are used to handle errors encountered during the execution of the operation-related code; A publishing module is used to publish the business source code, the operation-related code, the code operation environment and the execution file.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Front-end code encryption method and device, operation method and device, equipment and storage medium

    CN114035797A

  • Development data processing method, development data processing equipment and readable storage medium

    CN116860324A