Explorar el Código

dnet: move source files to src/, rename main.py to dnet and make executable

also rename default config to dnet_config.toml
lunar-mining hace 2 años
padre
commit
a4523f6017

+ 10 - 7
bin/dnet/main.py → bin/dnet/dnet

@@ -1,3 +1,5 @@
+#!/usr/bin/python3
+
 # This file is part of DarkFi (https://dark.fi)
 #
 # Copyright (C) 2020-2023 Dyne.org foundation
@@ -15,13 +17,14 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-import sys, toml, json, urwid, asyncio, logging, util
+import sys, toml, json, urwid, asyncio, logging
+import src.util
 
 from os.path import exists, join
 from pathlib import Path
-from model import Model
-from rpc import JsonRpc
-from view import View
+from src.model import Model
+from src.rpc import JsonRpc
+from src.view import View
 
 class Dnetview:
 
@@ -30,13 +33,13 @@ class Dnetview:
         asyncio.set_event_loop(self.ev)
         self.queue = asyncio.Queue()
 
-        os = util.get_os()
-        config_path = util.user_config_dir('darkfi', os)
+        os = src.util.get_os()
+        config_path = src.util.user_config_dir('darkfi', os)
 
         suffix = '.toml'
         filename = 'dnet_config'
         path = join(config_path, filename + suffix)
-        self.config = util.spawn_config(path)
+        self.config = src.util.spawn_config(path)
 
         self.model = Model()
         self.view = View(self.model)

+ 0 - 0
bin/dnet/config.toml → bin/dnet/dnet_config.toml


+ 0 - 0
bin/dnet/src/__init__.py


+ 0 - 0
bin/dnet/model.py → bin/dnet/src/model.py


+ 1 - 1
bin/dnet/rpc.py → bin/dnet/src/rpc.py

@@ -25,7 +25,7 @@ import asyncio
 class JsonRpc:
 
     async def start(self, host, port):
-        #logging.info(f"trying to connect to {host}:{port}")
+        logging.info(f"trying to connect to {host}:{port}")
         reader, writer = await asyncio.open_connection(host, port)
         self.reader = reader
         self.writer = writer

+ 0 - 0
bin/dnet/scroll.py → bin/dnet/src/scroll.py


+ 1 - 1
bin/dnet/util.py → bin/dnet/src/util.py

@@ -41,7 +41,7 @@ def spawn_config(path):
             cfg = toml.load(f)
             return cfg
     else:
-        with open('config.toml') as f:
+        with open('dnet_config.toml') as f:
             cfg = toml.load(f)
         with open(path, 'w') as f:
             toml.dump(cfg, f)

+ 2 - 2
bin/dnet/view.py → bin/dnet/src/view.py

@@ -20,8 +20,8 @@ import logging
 import asyncio
 import datetime as dt
 
-from scroll import ScrollBar, Scrollable
-from model import Model
+from src.scroll import ScrollBar, Scrollable
+from src.model import Model
 
 
 class DnetWidget(urwid.WidgetWrap):