Skip to content

Commit 44d0f87

Browse files
Krishna Tripathidhoomakethu
authored andcommitted
Merged in BEDGE-2726-make-pip-installable-version- (pull request #2)
BEDGE-2726 make pip installable version Approved-by: Sanjay K V <[email protected]>
2 parents cb786d2 + 98d373e commit 44d0f87

19 files changed

+86
-17
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ target/
6565
*.ini
6666

6767
#JSONFiles
68-
*.json
68+
*.json

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include requirements
2+
include README.md
3+
include modbus_simulator/assets/*.png
4+
include modbus_simulator/assets/*.ico
5+
include modbus_simulator/templates/*.kv

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ Modbus Simulator with GUI based on modbus-tk
2626
2727
## Running/Testing application
2828
$ ./tools/launcher
29-
29+
30+
or
31+
32+
With Pip
33+
34+
$ pip install modbus_simulator --extra-index-url http://pip.riptidieo.com/simple --trusted-host pip.riptideio.com
35+
$ modubus.simu
36+
`
3037
A GUi should show up if all the requirements are met !!
3138
3239
![Screen Shot 2015-11-01 at 7.25.50 PM.png](https://bitbucket.org/repo/X9byrq/images/4179375251-Screen%20Shot%202015-11-01%20at%207.25.50%20PM.png)

modbus_simulator/__init__.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

main.py renamed to modbus_simulator/main.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@
1212
from kivy.uix.settings import SettingsWithSidebar
1313
from kivy.uix.listview import ListView, ListItemButton
1414
from kivy.adapters.listadapter import ListAdapter
15-
from utils.modbus import ModbusSimu, BLOCK_TYPES, configure_modbus_logger
16-
from ui.settings import SettingIntegerWithRange
17-
from utils.backgroundJob import BackgroundJob
15+
from modbus_simulator.utils.modbus import ModbusSimu, BLOCK_TYPES, \
16+
configure_modbus_logger
17+
from modbus_simulator.ui.settings import SettingIntegerWithRange
18+
from modbus_simulator.utils.backgroundJob import BackgroundJob
1819
import re
1920
import os
2021
from json import load, dump
2122
from kivy.config import Config
2223
from kivy.lang import Builder
23-
import ui.datamodel
24+
import modbus_simulator.ui.datamodel
25+
from pkg_resources import resource_filename
26+
2427

2528
MAP = {
2629
"coils": "coils",
@@ -29,9 +32,12 @@
2932
'holding registers': 'holding_registers'
3033
}
3134

32-
SLAVES_FILE = 'slaves.json'
35+
settings_icon = resource_filename(__name__, "assets/Control-Panel.png")
36+
app_icon = resource_filename(__name__, "assets/riptideLogo.png")
37+
modbus_template = resource_filename(__name__, "templates/modbussimu.kv")
38+
Builder.load_file(modbus_template)
3339

34-
Builder.load_file("templates/modbussimu.kv")
40+
SLAVES_FILE = resource_filename(__name__, "slaves.json")
3541

3642

3743
class FloatInput(TextInput):
@@ -91,6 +97,9 @@ class Gui(BoxLayout):
9197
data_model_input_registers = ObjectProperty()
9298
data_model_holding_registers = ObjectProperty()
9399

100+
settings = ObjectProperty()
101+
riptide_logo = ObjectProperty()
102+
94103
reset_sim_btn = ObjectProperty()
95104

96105
# Helpers
@@ -114,6 +123,8 @@ class Gui(BoxLayout):
114123
def __init__(self, **kwargs):
115124
super(Gui, self).__init__(**kwargs)
116125
time_interval = kwargs.get("time_interval", 1)
126+
self.settings.icon = settings_icon
127+
self.riptide_logo.app_icon = app_icon
117128
self.config = Config.get_configparser('app')
118129
self.slave_list.adapter.bind(on_selection_change=self.select_slave)
119130
self.data_model_loc.disabled = True
@@ -1042,5 +1053,9 @@ def close_settings(self, *args):
10421053
super(ModbusSimuApp, self).close_settings()
10431054

10441055

1045-
if __name__ == "__main__":
1056+
def run():
10461057
ModbusSimuApp().run()
1058+
1059+
1060+
if __name__ == "__main__":
1061+
run()
File renamed without changes.

templates/modbussimu.kv renamed to modbus_simulator/templates/modbussimu.kv

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#:import KivyLexer kivy.extras.highlight.KivyLexer
33
#:import ListItemButton kivy.uix.listview.ListItemButton
44
#:import sla kivy.adapters.listadapter
5+
56
<Separator@Widget>
67
size_hint_y: None
78
thickness: 2
@@ -41,7 +42,10 @@
4142
slave_start_add: slave_start_add
4243
slave_end_add: slave_end_add
4344
action_bar: action_bar
45+
settings: settings
46+
riptide_logo: riptide_logo
4447
reset_sim_btn: reset_simulation
48+
4549
BoxLayout:
4650
padding: '2sp'
4751
canvas:
@@ -291,8 +295,8 @@
291295
ActionView:
292296
use_separator: True
293297
ActionPrevious:
298+
id: riptide_logo
294299
with_previous: False
295-
app_icon: 'assets/riptideLogo.png'
296300
disabled: True
297301
ActionOverflow:
298302
ActionButton:
@@ -303,8 +307,8 @@
303307
text: 'Simulate'
304308
on_release: root.start_stop_simulation(*args)
305309
ActionButton:
310+
id: settings
306311
text: 'settings'
307-
icon: 'assets/Control-Panel.png'
308312
on_release: app.show_settings(*args)
309313

310314

File renamed without changes.

ui/datamodel.py renamed to modbus_simulator/ui/datamodel.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
from kivy.uix.popup import Popup
1414
from kivy.uix.textinput import TextInput
1515

16-
from utils.backgroundJob import BackgroundJob
16+
from modbus_simulator.utils.backgroundJob import BackgroundJob
17+
from pkg_resources import resource_filename
1718

18-
Builder.load_file("templates/datamodel.kv")
19+
datamodel_template = resource_filename(__name__, "../templates/datamodel.kv")
20+
Builder.load_file(datamodel_template)
1921

2022
integers_dict = {}
2123

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

utils/modbus.py renamed to modbus_simulator/utils/modbus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from modbus_tk.modbus_rtu import RtuServer, RtuMaster
1010
from modbus_tk.modbus_tcp import TcpServer, TcpMaster
1111

12-
from utils.common import path, make_dir, remove_file
12+
from modbus_simulator.utils.common import path, make_dir, remove_file
1313

1414
ADDRESS_RANGE = {
1515
COILS: 0,

setup.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from setuptools import setup, find_packages
2+
3+
4+
def install_requires():
5+
with open('requirements') as reqs:
6+
install_req = [
7+
line for line in reqs.read().split('\n')
8+
]
9+
return install_req
10+
11+
12+
def readme():
13+
with open("README.md") as f:
14+
return f.read()
15+
16+
17+
setup(
18+
name="modbus_simulator",
19+
url="https://bitbucket.org/riptideio/modbus-simulator",
20+
version="0.1",
21+
description="Modbus Simulator using modbus_tk and kivy",
22+
long_description=readme(),
23+
keywords="Modbus Simulator",
24+
author="riptideio",
25+
packages=find_packages(),
26+
install_requires=install_requires(),
27+
entry_points={
28+
'console_scripts': [
29+
'modbus.simu = modbus_simulator.main:run',
30+
],
31+
},
32+
include_package_data=True
33+
)

tools/launcher

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22

3-
root_dir="$(cd $(dirname $0)/..; pwd)"
4-
launch_cmd="$root_dir/main.py"
5-
python $launch_cmd
3+
echo $0
4+
root_dir="$(cd $(dirname $0)/../; pwd)"
5+
simu_dir="$root_dir/modbus_simulator"
6+
export PYTHONPATH=$root_dir
7+
launch_cmd="$simu_dir/main.py"
8+
python $launch_cmd

0 commit comments

Comments
 (0)