区块链web3项目系统开发技术方案丨DAPP系统开发技术讲解

  作为一种可能的Web3.0底层技术,区块链以去中心化、不可篡改、可溯源等特点,构建起数字经济时代的全新信任体系。

  从技术角度分析,区块链让数字资产价值流转的每一个节点都公开透明、有迹可循且不可篡改,这将会让Web3.0时代的一切交易变得更加真实可信。

应用场景

在容器内部,想要获取容器名称,替换容器内某些文件内的字符串, 代码如下:

# -*-coding:utf-8-*-
import os
import redis


def alter(file, new_str, old_str="abc_123abc"):
    """
    替换文件中的字符串
    file:文件名
    old_str:就字符串
    new_str:新字符串
    """

    file_data = ""
    with open(file, "r") as f:
        for line in f:
            if old_str in line:
                line = line.replace(old_str, new_str)
            file_data += line
    with open(file, "w") as f:
        f.write(file_data)


def get_container_name():
    db = redis.Redis(host="192.168.0.111", port=6380, decode_responses=False)
   
    # start: in container, run next code  -------------------------------------------------
    cmd = "cat /proc/self/cgroup"
    output = os.popen(cmd)
    rests = output.readlines()
    container_message= rests[-1]
    if not container_message:
        container_id = "abc"
    else:
        container_id =  container_message.strip().split("docker-")[-1][:12]
    # end. ----------------------------------------------------------------------------------

    container_name = None
    if container_id != "abc":
        key_name = "nm_" + container_id
        container_name = db.hget("container_msg", key_name)

    if container_name:
        container_name = container_name.decode("utf-8")

    return container_name


def run():
    nginx_conf = "/etc/nginx/nginx.conf"
    galaxy_yml = "/galaxy-central/config/galaxy.yml"

    container_name = get_container_name()
    if container_name is not None:
        alter(nginx_conf, container_name)
        os.popen("nginx -s reload")
        # os.popen("cp /galaxy-central/config/galaxy.yml.sample /galaxy-central/config/galaxy.yml")
        alter(galaxy_yml, container_name)
        print("Replacement string 'abc_123abc' succeeded")
    else:
        print("Replacement string 'abc_123abc' failed")
        

if __name__ == '__main__':
    run()

  Nansen则将链上数据与包含数百万个用于投资组合分析标签的数据库相结合,助力使用者发现市场机会。

  上述区块链数据服务企业有着共同的方向,即从一开始的链上数据分析,拓展到了更深层次的业务数据分析,而业务数据的四个特点也愈发明显:单数据的价值维度低、数据呈现指数级增长、海量数据等待处理、数据结构愈加复杂化。

import os
    # 目标路径
    path = "C:\\Users\\username\\Desktop\\project"
    dir_list = []
    # os.walk() 自上而下或自下而上,遍历出所有文件。返回值 可迭代对象  
    # 当前路径(str),所有文件夹(list),所有文件(list)
    for dirpath, dirnames, filenames in os.walk(path):
        for filepath in filenames:
            print(os.path.join(dirpath, filepath))
            if os.path.join(dirpath, filepath).endswith(".py"):
                dir_list.append(os.path.join(dirpath, filepath))
        print(dir_list)

    for dir in dir_list:
        with open(dir, encoding="utf-8") as f:
            content = f.read()

        with open("project.txt", "a", encoding="utf-8") as file:
            file.write(content)

未经允许不得转载:木盒主机 » 区块链web3项目系统开发技术方案丨DAPP系统开发技术讲解

赞 (0)

相关推荐

    暂无内容!