Rod-Persky / investoscope-easy-update

Updates Investoscope 3 end of day quotes
GNU General Public License v3.0
6 stars 3 forks source link

App needs UI to set Investoscope path / location #6

Closed jashsayani closed 4 years ago

jashsayani commented 6 years ago

The app just runs the python script that is bundled as a resource. This has the investoscope path hard-coded to user directory. My directory is inside iCloud Drive. App should let the user set this directory.

charlietomo commented 6 years ago

I agree that it would be good for the app to let the user configure this directory - or at least give an error if no directory / file is found.

However you can manually change the path by editing the investoscope.py file inside of the app (right click, "Show Package Contents") and then the app will run and work with the directory elsewhere.

jashsayani commented 6 years ago

I did that but it might not be obvious to everyone else.

Rod-Persky commented 6 years ago

+1 will find out how to fix

Rod-Persky commented 6 years ago
Rod-Persky commented 5 years ago

Yeah so I haven't done anything about this... I should really check how investoscope deals with changing the location.

KhaineBOT commented 5 years ago

@Rod-Persky how about in the interim, you just load in data from a settings file? That should be relatively simple and potentially easier for a user to modify

Something like this should work:

###### global refs #########

INVESTOSCOPE_CONFIG ="./investoscope.conf"

#######################

def loadConfig(INVESTOSCOPE_CONFIG):
    from configparser import ConfigParser

    try:

        config = ConfigParser()
        config.read(INVESTOSCOPE_CONFIG)

    except IOError as e:
        if hasattr(e, 'reason'):
            print (e.reason)

    global INVESTOSCOPE_PATH

    INVESTOSCOPE_PATH = config.get('main','INVESTOSCOPE_PATH')

######## main ################

loadConfig(INVESTOSCOPE_CONFIG)

Then the config file would have something like this in it:

[main]
INVESTOSCOPE_PATH = ~/.investoscope/

I've quickly tested this code and it should work, probably should add some data validation if the config doesn't exist and what not. I can submit a pull request with this code if it will help

Henry-Walpole commented 4 years ago

Hi, I'm trying to get this working by manually changing the path as mentioned at the top of this thread. My Investoscope is at macOS Sierra/users/henrywalpole/Documents/Investoscope Within that I have a folder My Backups

I'm not sure what I need to set INVESTOSCOPE_PATH to? Also do I need to create the file csv_data if so what should it contain and where do I place it?

Many thanks for any help - it would be so good to bring Investoscope 3 back to updating quotes!

charlietomo commented 4 years ago

Hi @Henry-Walpole it sounds like you have found the file you need to edit, and the folder. Are you getting an error?

An example of my setup INVESTOSCOPE_PATH = "/Users/name/Dropbox/Investoscope" and in that folder I have the data4.issqlite file which is, as I understand it, the file that the script grabs the instrument details from.

You mention My Backups but I have no idea what that is? You mention csv_data but again I am not sure what you mean. I do not recall having to do anything with it.

Also check after an update as I find not all Yahoo data is good - but much better than nothing!

Henry-Walpole commented 4 years ago

Hi @charlietomo many thanks for the response, yes I'm seeing the following error:

​Traceback (most recent call last): File "update.py", line 7, in <module> import investoscope File "/private/var/folders/yj/jd0qrmnn2s38fmrh__hqc9qm0000gn/T/AppTranslocation/C2B539B4-E1E3-4DCA-AF62-C13ECBD66E3E/d/Investoscope Updater.app/Contents/Resources/investoscope.py", line 23, in <module> CSV_DOWNLOAD_PATH.mkdir(exist_ok=True) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/pathlib.py", line 1266, in mkdir self._accessor.mkdir(self, mode) FileNotFoundError: [Errno 2] No such file or directory: '/Users/henrywalpole/.investoscope/csv_data'

The My Backups folder I think is just a folder I must have created originally within the Investoscope folder to hold my personal backups so is probably not relevant.

The csv_data is mentioned in the error message.

Note the above error occurs with the default INVESTOSCOPE_PATH = "~/.investoscope" I'm really not sure what this should be set to, when I tried INVESTOSCOPE_PATH = "/Users/henrywalpole/Documents/Investoscope"

I get the following error:

​/private/var/folders/yj/jd0qrmnn2s38fmrh__hqc9qm0000gn/T/AppTranslocation/10956977-F2C6-4165-8B2E-B8959AAE3175/d/Investoscope Updater.app/Contents/Resources/investoscope.py:57: SyntaxWarning: "is not" with a literal. Did you mean "!="? if process.returncode is not 0: Traceback (most recent call last): File "update.py", line 7, in <module> import investoscope File "/private/var/folders/yj/jd0qrmnn2s38fmrh__hqc9qm0000gn/T/AppTranslocation/10956977-F2C6-4165-8B2E-B8959AAE3175/d/Investoscope Updater.app/Contents/Resources/investoscope.py", line 26, in <module> sys.exit(0) NameError: name 'sys' is not defined

Thanks again for any help you can offer.

Henry-Walpole commented 4 years ago

Sorted this in the end. Once I determined the correct Investoscope path (I was using the wrong one) and installed the requests module (I'd assumed it was already installed) then this works fine. Really pleased to have the ability to get prices updated automatically. I'd been doing them manually as I have not found anything to replace Investoscope. Thanks @Rod-Persky for coding this!

charlietomo commented 4 years ago

Glad you got this sorted @Henry-Walpole.

Rod-Persky commented 4 years ago

Awesome! and thanks @charlietomo 🎉