Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User prompt improvements #242

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ Install python via Anaconda and then PASTA-ELN
If you do not have Python installed, we recommend using Anaconda.
1. Go to https://www.anaconda.com/download
2. Download installer and run install. Accept all defaults
3. Create environment, e.g. PASTA-ELN
4. Open environment in command-prompt
3. Create environment, e.g. PASTA-ELN and choose to install it with "Python 3.11..."
4. Click on new green arrow button and open "Terminal"
5. "pip install pasta-eln"
6. "python -m pasta_eln.gui"
6. "pip install pasta-eln -U --no-dependencies"

- if it complains about 'aiohttp' missing "pip install aiohttp"

7. "python -m pasta_eln.gui" (make sure that you have administrator rights)


Manual installation
Expand Down
25 changes: 18 additions & 7 deletions pasta_eln/GUI/configSetupWindows.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
""" Widget: setup tab inside the configuration dialog window """
import logging
import logging, os, ctypes
from enum import Enum
from pathlib import Path
from typing import Callable, Any
Expand Down Expand Up @@ -76,12 +76,23 @@ def execute(self, command:list[Any]) -> None:
else:
button = QMessageBox.question(self, "CouchDB installation", couchDBWindows)
if button == QMessageBox.Yes:
res = couchdb('install')
flagInstalledSoftware = True
if len(res.split('|'))==3:
password=res.split('|')[1]
try:
isAdmin = os.getuid() == 0
except AttributeError:
isAdmin = ctypes.windll.shell32.IsUserAnAdmin() == 1 # type: ignore[attr-defined]
if not isAdmin:
QMessageBox.information(self,'Administrator rights required', \
'You require administrator rights for your user. I exit installation now.')
self.mainText = self.mainText.replace('- CouchDB','- CouchDB: no admin rights' )
self.text1.setMarkdown(self.mainText)
flagContinue = False
else:
logging.error('Could not retrieve password :%s',str(res))
res = couchdb('install')
flagInstalledSoftware = True
if len(res.split('|'))==3:
password=res.split('|')[1]
else:
logging.error('Could not retrieve password :%s',str(res))
else:
self.mainText = self.mainText.replace('- CouchDB','- CouchDB: user chose to NOT install' )
self.text1.setMarkdown(self.mainText)
Expand Down Expand Up @@ -131,7 +142,7 @@ def execute(self, command:list[Any]) -> None:

#If installed, restart
if flagInstalledSoftware:
button = QMessageBox.information(self,'PASTA-ELN restart required', restartPastaWindows)
QMessageBox.information(self,'PASTA-ELN restart required', restartPastaWindows)
restart()

#Example data
Expand Down
4 changes: 2 additions & 2 deletions pasta_eln/installationTools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
''' Methods that check, repair, the local PASTA-ELN installation '''
''' Methods that check, repair, the local PASTA-ELN installation: no Qt-here '''
import os, platform, sys, json, shutil, random, string, logging, uuid
from typing import Optional, Any, Callable
import urllib.request
Expand Down Expand Up @@ -114,7 +114,7 @@ def couchdb(command:str='test') -> str:
elif command == 'install':
if platform.system()=='Linux':
return '**ERROR should not be called'
elif platform.system()=='Windows':
if platform.system()=='Windows':
logging.info('CouchDB starting ...')
url = 'https://couchdb.neighbourhood.ie/downloads/3.1.1/win/apache-couchdb-3.1.1.msi'
path = Path.home()/'Downloads'/'apache-couchdb-3.1.1.msi'
Expand Down
4 changes: 2 additions & 2 deletions pasta_eln/serverActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def backupCouchDB(location:str='', userName:str='', password:str='') -> None:
if location=='local':
location = '127.0.0.1'
if not userName:
userName = input('Enter username: ').strip()
userName = input('Enter local admin username: ').strip()
if not password:
password = input('Enter password: ').strip()
elif location=='remote':
Expand Down Expand Up @@ -518,7 +518,7 @@ def main() -> None:
url, administrator, password = myString.split(':')
print("URL and credentials successfully read from keyring")
except Exception:
print("Could not get credentials from keyring.")
print("Could not get credentials for the remote server from keyring.")
## URL
url = input('Enter the URL without http and without port: ')
if len(url)<2:
Expand Down
Loading