Skip to content

Commit

Permalink
Default Config Generation fixed for new users
Browse files Browse the repository at this point in the history
  • Loading branch information
pranjal-joshi committed Aug 23, 2021
1 parent f9f350a commit 066c5c2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
7 changes: 6 additions & 1 deletion src/classes/Changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from classes.ColorText import colorText

VERSION = "1.24"
VERSION = "1.25"

changelog = colorText.BOLD + '[ChangeLog]\n' + colorText.END + colorText.BLUE + '''
[1.00 - Beta]
Expand Down Expand Up @@ -119,5 +119,10 @@
3. Permission bug-fixes for some windows users.
4. Result table optimized.
[1.25]
1. Default configuration parameters optimized.
2. Configuration generation on first time usage don't need restart anymore!
3. Minor bug-fixes.
--- END ---
''' + colorText.END
38 changes: 24 additions & 14 deletions src/classes/ConfigManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def __init__(self):
self.volumeRatio = 2
self.minLTP = 20.0
self.maxLTP = 50000
self.period = '365d'
self.period = '300d'
self.duration = '1d'
self.daysToLookback = 30
self.shuffleEnabled = False
self.cacheEnabled = False
self.shuffleEnabled = True
self.cacheEnabled = True
self.stageTwo = False
self.useEMA = True
self.useEMA = False

def deleteStockData(self,excludeFile=None):
for f in glob.glob('stock_data*.pkl'):
Expand All @@ -42,7 +42,7 @@ def deleteStockData(self,excludeFile=None):

# Handle user input and save config

def setConfig(self, parser, default=False):
def setConfig(self, parser, default=False, showFileCreatedText=True):
if default:
parser.add_section('config')
parser.set('config', 'period', self.period)
Expand All @@ -56,19 +56,20 @@ def setConfig(self, parser, default=False):
parser.set('config', 'shuffle', 'y')
parser.set('config', 'cacheStockData', 'y')
parser.set('config', 'onlyStageTwoStocks', 'y')
parser.set('config', 'useEMA', 'y')
parser.set('config', 'useEMA', 'n')
try:
fp = open('screenipy.ini', 'w')
parser.write(fp)
fp.close()
print(colorText.BOLD + colorText.GREEN +
'[+] Default configuration generated as user configuration is not found!' + colorText.END)
print(colorText.BOLD + colorText.GREEN +
'[+] Use Option > 5 to edit in future.' + colorText.END)
print(colorText.BOLD + colorText.GREEN +
'[+] Close and Restart the program now.' + colorText.END)
input('')
sys.exit(0)
if showFileCreatedText:
print(colorText.BOLD + colorText.GREEN +
'[+] Default configuration generated as user configuration is not found!' + colorText.END)
print(colorText.BOLD + colorText.GREEN +
'[+] Use Option > 5 to edit in future.' + colorText.END)
print(colorText.BOLD + colorText.GREEN +
'[+] Close and Restart the program now.' + colorText.END)
input('')
sys.exit(0)
except IOError:
print(colorText.BOLD + colorText.FAIL +
'[+] Failed to save user config. Exiting..' + colorText.END)
Expand Down Expand Up @@ -179,3 +180,12 @@ def showConfigFile(self):
print(colorText.BOLD + colorText.WARN +
"[+] Configure the limits to continue." + colorText.END)
self.setConfig(parser)

# Check if config file exists
def checkConfigFile(self):
try:
f = open('screenipy.ini','r')
f.close()
return True
except FileNotFoundError:
return False
6 changes: 3 additions & 3 deletions src/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
5. Bug-fixes & Performance upgrades for MultiCore CPUs. :gear:

## Downloads
* For :desktop_computer: **Windows** users, download **[screenipy.exe](https://github.com/pranjal-joshi/Screeni-py/releases/download/1.24/screenipy.exe)**
* For :penguin: **Linux** users, download **[screenipy.bin](https://github.com/pranjal-joshi/Screeni-py/releases/download/1.24/screenipy.bin)**
* For :apple: **MacOS** users, download **[screenipy.run](https://github.com/pranjal-joshi/Screeni-py/releases/download/1.24/screenipy.run)** ([Read Installation Guide](https://github.com/pranjal-joshi/Screeni-py/blob/main/INSTALLATION.md#for-macos))
* For :desktop_computer: **Windows** users, download **[screenipy.exe](https://github.com/pranjal-joshi/Screeni-py/releases/download/1.25/screenipy.exe)**
* For :penguin: **Linux** users, download **[screenipy.bin](https://github.com/pranjal-joshi/Screeni-py/releases/download/1.25/screenipy.bin)**
* For :apple: **MacOS** users, download **[screenipy.run](https://github.com/pranjal-joshi/Screeni-py/releases/download/1.25/screenipy.run)** ([Read Installation Guide](https://github.com/pranjal-joshi/Screeni-py/blob/main/INSTALLATION.md#for-macos))

## How to use?

Expand Down
2 changes: 2 additions & 0 deletions src/screenipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ def main(testing=False):
if __name__ == "__main__":
Utility.tools.clearScreen()
isDevVersion = OTAUpdater.checkForUpdate(proxyServer, VERSION)
if not configManager.checkConfigFile():
configManager.setConfig(ConfigManager.parser, default=True, showFileCreatedText=False)
try:
while True:
main()
Expand Down

0 comments on commit 066c5c2

Please sign in to comment.