Skip to content

Commit

Permalink
Merge pull request #23 from marmarachain/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
rumeysayilmaz committed Dec 17, 2021
2 parents 9c76101 + 48f133f commit 8c6b710
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 36 deletions.
2 changes: 1 addition & 1 deletion requirements
@@ -1,4 +1,4 @@
pip==21.2.4
pip==21.3.1
fbs==0.9.0
qrcode==7.2
paramiko==2.7.2
Expand Down
2 changes: 1 addition & 1 deletion src/build/settings/base.json
Expand Up @@ -2,6 +2,6 @@
"app_name": "MarmaraConnector",
"author": "Marmara Credit Loops",
"main_module": "src/main/python/mainApp.py",
"version": "0.3.4-alpha",
"version": "0.3.5-alpha",
"public_settings": ["app_name", "author", "version"]
}
6 changes: 3 additions & 3 deletions src/main/python/configuration.py
Expand Up @@ -27,9 +27,9 @@

log_file_path = os.path.join(config_directory_path, "marmara-connector.log") # configure log file directory
logging.getLogger(__name__)
stream_handler = logging.StreamHandler() # create stream handler and set level to debug
stream_handler.setLevel(logging.DEBUG) # set stream handler level to debug
logging.basicConfig(level=logging.DEBUG,
stream_handler = logging.StreamHandler() # create stream handler and set level to info
stream_handler.setLevel(logging.INFO) # set stream handler level to info
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)s %(name)s:%(module)s %(funcName)s:%(lineno)s %(message)s',
handlers=[logging.FileHandler(filename=log_file_path, mode='a+'), stream_handler])

Expand Down
56 changes: 37 additions & 19 deletions src/main/python/mainApp.py
Expand Up @@ -573,8 +573,6 @@ def check_marmara_path(self):

@pyqtSlot(str)
def check_marmara_path_output(self, output):
logging.info('Checking marmara path')
logging.info('login:' + output)
if output == 'get marmarad path':
self.login_page_info(self.tr('Getting marmara chain path from config file'))
logging.info('Getting marmara chain path from config file')
Expand Down Expand Up @@ -989,20 +987,20 @@ def toggle_staking(self):
if message_box == QMessageBox.Yes:
self.mining_button.setChecked(False) # Close mining and set staking mode
self.cpu_core_selection_off()
logging.debug('setgenerate True 0')
logging.info('setgenerate True 0')
self.setgenerate([True, 0])
if message_box == QMessageBox.No: # Abort selecting staking and continue mining
self.staking_button.setChecked(False)
else: # set staking mode
logging.debug('setgenerate True 0')
logging.info('setgenerate True 0')
self.setgenerate([True, 0])
else: # Staking button status is False
message_box = self.custom_message(self.tr('Turning off Staking'),
self.tr('You are about to turn off staking. Are you sure?'), "question",
QMessageBox.Question)

if message_box == QMessageBox.Yes:
logging.debug('setgenerate False')
logging.info('setgenerate False')
self.setgenerate([False])
if message_box == QMessageBox.No:
self.staking_button.setChecked(True) # Abort selecting staking button
Expand All @@ -1018,21 +1016,21 @@ def toggle_mining(self):
QMessageBox.Question)
if message_box == QMessageBox.Yes:
self.staking_button.setChecked(False) # Close staking and turn on mining
logging.debug('setgenerate True 1')
logging.info('setgenerate True 1')
self.setgenerate([True, 1])
self.cpu_core_selection_on()
if message_box == QMessageBox.No: # Abort selecting mining and continue staking
self.mining_button.setChecked(False)
else: # Staking is off turn on Mining mode
logging.debug('setgenerate True 1')
logging.info('setgenerate True 1')
self.cpu_core_selection_on()
self.setgenerate([True, 1])
else: # Mining button status is False.
message_box = self.custom_message(self.tr('Turning off Mining'),
self.tr('You are about to turn off mining. Are you sure?'), "question",
QMessageBox.Question)
if message_box == QMessageBox.Yes:
logging.debug('setgenerate False')
logging.info('setgenerate False')
self.cpu_core_selection_off()
self.setgenerate([False])
if message_box == QMessageBox.No:
Expand All @@ -1058,7 +1056,7 @@ def setgenerate(self, arg):
@pyqtSlot(tuple)
def setgenerate_result(self, result_out):
if result_out[0]:
logging.debug('\n---- getgenerate result------\n' + str(json.loads(result_out[0])))
logging.info('\n---- getgenerate result------\n' + str(json.loads(result_out[0])))
result = json.loads(result_out[0])
if result.get('staking') is True and result.get('generate') is False:
self.bottom_info(self.tr('Staking ON'))
Expand Down Expand Up @@ -1257,8 +1255,8 @@ def set_pubkey_result(self, result_out):
def start_chain_with_pubkey(self):
button = self.sender()
index = self.addresses_tableWidget.indexAt(button.pos())
logging.debug(index.row())
logging.debug(index.column())
logging.info(index.row())
logging.info(index.column())
if index.isValid():
pubkey = self.addresses_tableWidget.item(index.row(), 3).text()
self.start_chain_settings(pubkey)
Expand Down Expand Up @@ -1886,7 +1884,7 @@ def getaddresstxids_result(self, result_out):
for txid in result_out[0]:
self.bottom_info(self.tr("fetched transactions between selected dates."))
row_number = result_out[0].index(txid)
btn_explorer = QPushButton(qta.icon('mdi.firefox'), '')
btn_explorer = QPushButton(qta.icon('mdi.firefox', color='#728FCE'), '')
btn_explorer.setIconSize(QSize(24, 24))
txid_date = datetime.fromtimestamp(txid[2]).date()
self.transactions_tableWidget.setCellWidget(row_number, 0, btn_explorer)
Expand Down Expand Up @@ -2008,7 +2006,7 @@ def set_credit_request_table(self, credit_request_list):
self.loop_request_tableWidget.setColumnHidden(5, True)
for row in credit_request_list:
row_number = credit_request_list.index(row)
btn_review = QPushButton(qta.icon('mdi.text-box-check-outline'), '')
btn_review = QPushButton(qta.icon('mdi.text-box-check-outline', color='#728FCE'), '')
btn_review.setIconSize(QSize(24, 24))
self.loop_request_tableWidget.setCellWidget(row_number, 0, btn_review)
self.loop_request_tableWidget.setItem(row_number, 1, QTableWidgetItem(str(row[0])))
Expand Down Expand Up @@ -2037,7 +2035,7 @@ def set_transfer_request_table(self, transfer_request_list):
self.transferrequests_tableWidget.setColumnHidden(5, True)
for row in transfer_request_list:
row_number = transfer_request_list.index(row)
btn_review = QPushButton(qta.icon('mdi.text-box-check-outline'), '')
btn_review = QPushButton(qta.icon('mdi.text-box-check-outline', color='#728FCE'), '')
btn_review.setIconSize(QSize(24, 24))
self.transferrequests_tableWidget.setCellWidget(row_number, 0, btn_review)
self.transferrequests_tableWidget.setItem(row_number, 1, QTableWidgetItem(str(row[0])))
Expand Down Expand Up @@ -2225,6 +2223,7 @@ def loops_details_result(self, result_out):
if result_out[2] == 0:
self.set_activeloops_table(result_out[0])
self.set_loop_amount_result(result_out[1])
self.refresh_loopinfo_button.setVisible(True)
if result_out[2] == 1:
print(result_out[1])
self.bottom_err_info(result_out[1])
Expand Down Expand Up @@ -2421,14 +2420,33 @@ def search_loop_txid_result(self, result_out):
if result.get('result') == "error":
self.bottom_info(result.get('error'))
self.clear_lq_txid_search_result()
if result.get('result') == "success":
else:
creditloop = result.get('creditloop')
self.loopquery_baton_value.setText(str(result.get('batontxid')))
self.loopquery_amount_value.setText(str(result.get('amount')))
if str(result.get('funcid')) == 'S':
baton = str(result.get('settlement'))
batonpk = str(result.get('pubkey'))
amount = str(result.get('collected'))
self.loopquery_baton_label.setText(self.tr('Txid (Settlement)'))
issuerpk = str((creditloop[0]).get('issuerpk'))
elif str(result.get('funcid')) == 'B':
issuerpk = str(result.get('issuerpk'))
amount = str(result.get('amount'))
baton = str(result.get('createtxid'))
batonpk = str(self.tr('Not issued yet!'))
self.loopquery_baton_label.setText(self.tr('Txid (baton)'))
else:
baton = str(result.get('batontxid'))
batonpk = str(result.get('batonpk'))
amount = str(result.get('amount'))
issuerpk = str((creditloop[0]).get('issuerpk'))
self.loopquery_baton_label.setText(self.tr('Txid (baton)'))

self.loopquery_baton_value.setText(baton)
self.loopquery_amount_value.setText(amount)
self.loopquery_currency_value.setText(result.get('currency'))
self.loopquery_matures_value.setText(str(result.get('matures')))
self.loopquery_batonpk_value.setText(str(result.get('batonpk')))
self.loopquery_issuer_value.setText(str((creditloop[0]).get('issuerpk')))
self.loopquery_batonpk_value.setText(batonpk)
self.loopquery_issuer_value.setText(issuerpk)
self.loopquery_transfercount_value.setText(str(result.get('n')))
self.bottom_info(self.tr('credit loop info finished'))
logging.info('credit loop info finished')
Expand Down
18 changes: 6 additions & 12 deletions src/main/python/marmarachain_rpc.py
Expand Up @@ -68,7 +68,7 @@ def do_search_path(cmd):
mcl_path = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
mcl_path.wait()
mcl_path.terminate()
return mcl_path.stdout.read().decode("utf8").split('\n'), mcl_path.stdout.read().decode("utf8").split('\n')
return mcl_path.stdout.read().decode().split('\n'), mcl_path.stdout.read().decode().split('\n')
except Exception as error:
logging.error(error)
else:
Expand Down Expand Up @@ -197,7 +197,7 @@ def mcl_chain_status():
marmarad_pid = subprocess.Popen(marmara_pid, shell=True, stdout=subprocess.PIPE)
marmarad_pid.wait()
marmarad_pid.terminate()
return marmarad_pid.stdout.read().decode("utf8"), marmarad_pid.stdout.read().decode("utf8")
return marmarad_pid.stdout.read().decode(), marmarad_pid.stdout.read().decode()
except Exception as error:
logging.error(error)
else:
Expand Down Expand Up @@ -517,13 +517,11 @@ def extract_bootstrap(self):
def do_execute_extract(self, cmd_list):
pwd_home = str(pathlib.Path.home())
for cmd in cmd_list:
print(cmd)
proc = subprocess.Popen(cmd, cwd=pwd_home, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
retvalue = proc.poll()
while True:
stdout = proc.stdout.readline().replace(b'\n', b'').replace(b'\r', b'').decode()
self.output.emit(str(stdout))
print(stdout)
logging.info(str(stdout))
if not stdout:
break
Expand All @@ -549,7 +547,7 @@ def get_loop_detail(self, txid, holder=False):
break
return [txid, loop_amount, pubkey, loop_matures, loop_create_block, loop_address]
else:
print(loop_detail[1])
logging.error(loop_detail[1])
return False

@pyqtSlot()
Expand All @@ -566,7 +564,6 @@ def active_loops_details(self):
issuer_details_list.append(issuance_details)
else:
logging.error('some error in getting loopdetail')
print('some error in getting loopdetail')
self.finished.emit()
break
result = issuer_details_list, marmarainfo_result, 0
Expand All @@ -591,7 +588,6 @@ def holder_loop_detail(self):
holder_details_list.append(issuance_details)
else:
logging.error('some error in getting loopdetail')
print('some error in getting loopdetail')
self.finished.emit()
break
result = holder_details_list, holer_result, 0
Expand Down Expand Up @@ -669,7 +665,7 @@ def linux_install(self):
cmd = self.linux_command_list[i]
if cmd.startswith('sudo'):
cmd = 'sudo -k -S -- ' + cmd + '\n'
logging.debug(cmd)
logging.info(cmd)
if is_local:
proc = subprocess.Popen(cmd, cwd=str(pathlib.Path.home()), shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Expand All @@ -686,7 +682,7 @@ def linux_install(self):
if not out:
proc.stdout.close()
exit_status = proc.poll()
logging.debug('exit_status :' + str(exit_status))
logging.info('exit_status :' + str(exit_status))
proc.terminate()
i = i + 1
if i >= len(self.linux_command_list):
Expand Down Expand Up @@ -740,7 +736,7 @@ def windows_install(self):
self.progress.emit(10)
else:
cwd = str(pathlib.Path.home()) + '\marmara'
logging.debug(cwd)
logging.info(cwd)
proc = subprocess.Popen(cmd, cwd=cwd, shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while not proc.stdout.closed:
Expand All @@ -749,7 +745,6 @@ def windows_install(self):
out_d = out.decode()
except:
out_d = '*-*-'
print(out_d)
self.out_text.emit(out_d)
if not out:
proc.stdout.close()
Expand Down Expand Up @@ -807,7 +802,6 @@ def remote_chain_update(self):
self.mcl_linux_zipname, 'unzip -o ' + marmara_path + self.mcl_linux_zipname + ' -d ' + marmara_path]
sshclient = remote_connection.server_ssh_connect()
for cmd in cmd_list:
print(cmd)
session = sshclient.get_transport().open_session()
session.set_combine_stderr(True)
session.get_pty()
Expand Down

0 comments on commit 8c6b710

Please sign in to comment.