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

[Windows] Change CONFIG.dat file location, behavior #335

Merged
merged 11 commits into from
Jan 27, 2016

Conversation

MCGallaspy
Copy link
Contributor

Still a WIP. Will fix #321.

Todo:

  • Remove the ability to create CONFIG.dat at install time
  • Write CONFIG.dat to a location determined by the user running KA Lite.exe
  • Do some clean-up refactoring on config.h.
  • Migrate data from location dependent on Windows version to installing user's ~/.kalite dir.
  • Change the start at boot option so that it run's as the current user instead of SYSTEM

Will appreciate a code review. I am but an egg with C++\Windows dev. Willing to discuss in great detail.

Signatures of some functions were changed to be more restrictive
and expressive. Partly style, partly to let the compiler catch errors.
CONFIG.dat file will appear in the user's AppData directory now.
Also refactor a bit: define function for getting CONFIG.dat path,
joining filesystem paths (it's not very smart though, but better
than pulling in the .NET framework to get the right function),
and use new signature for formatResultBuffer.
@MCGallaspy MCGallaspy added the bug label Jan 7, 2016
@MCGallaspy MCGallaspy added this to the 0.16.0 milestone Jan 7, 2016
@MCGallaspy MCGallaspy changed the title 321 config file [Windows] Change CONFIG.dat file location, behavior Jan 7, 2016
@radinamatic
Copy link
Member

I am but an egg with C++\Windows dev

Then I must be a proto-idea of an egg... 😛
Ping me as I want to sit in on that code review!

Replace wchar string literals with by wrapping them in the
TEXT(...) macro, which uses char or wchar depending on whether
the UNICODE preprocessor variable is defined. Makes code portable!

Refactor writeConfigurationFileBuffer -- there seems to have been
unreachable code.

Refactor searchKeyIndex to be more concise.
Also refactor to remove global variable prevVerStr.
@MCGallaspy
Copy link
Contributor Author

@radinamatic this should almost be ready for testing. I just want to give it a sanity check before unleashing you on it in full force.

@radinamatic
Copy link
Member

before unleashing you on it in full force.

This makes me sound like a bloodhound. You guys must still see me as an enforcer of sorts 😜

@MCGallaspy
Copy link
Contributor Author

We still have pending the issue of how is KA Lite going to be started, right?

Yes. Let me add an item for that. That said, it shouldn't affect this too much. Can you download the installer, and ensure that it just installs okay, then I'll push that change and we can start testing upgrading/start at boot behavior?

@MCGallaspy
Copy link
Contributor Author

Once I push the change, I'd like to test it out like the following scenarios:

  • Test "fresh" installs on each version of Windows*.
  • Test upgrading on at least one version of windows for 0.12.
  • Test upgrading on at least one version of windows for 0.13.
  • Test upgrading on at least one version of windows for 0.14 when the user has already used the start at boot option (and thus has data in the SYSTEM's profile which must be migrated).
  • Test upgrading on at least one version of windows for 0.15 when the user has already used the start at boot option.

Maybe others?

@radinamatic
Copy link
Member

Sounds fine by me, to begin with.. If something pops up that needs a more specific scenario, we'll get to it after this...

If you didn't push this yet, should I still test the # 101 build?

@MCGallaspy
Copy link
Contributor Author

@radinamatic should be good to go with build 102.

@radinamatic
Copy link
Member

Ok, will download now and start testing tomorrow! 👍

@radinamatic
Copy link
Member

Hm, the version check might not be working correctly: it seems to detect the previous installation on VM snapshots (of 2 different Windows 7 machines) that do not have any.

I've searched the registry for any KA Lite keys/values, and found only a couple which I suppose are some kind of cache for the current build instal. @MCGallaspy

ie9 - win7 ready for ka lite running - oracle vm virtualbox_143

@radinamatic
Copy link
Member

And no wonder it reports an error afterwards:

ie9 - win7 ready for ka lite running - oracle vm virtualbox_144

@radinamatic
Copy link
Member

Regarding the Something went wrong... in the previous screenshot: this is one of my personal pet peeves, because of its total uselessness for the user.

In case of legit upgrade scenario (and not with detection of non-existing previous installation), at this point the installer should include the option for the users to choose the old-version content folder themselves. Could we try to implement that?

@radinamatic
Copy link
Member

On another hand, # 102 build behaves the same on Windows XP. This time though, I chose not to "upgrade", and the installer could not proceed, since there was no old database to delete... 😛

ie8 - winxp ready for ka lite running - oracle vm virtualbox_145

@MCGallaspy
Copy link
Contributor Author

In case of legit upgrade scenario (and not with detection of non-existing previous installation), at this point the installer should include the option for the users to choose the content folder themselves. Could we try to implement that?

Yeah, this is a legitimate point. Please open an issue for it, I'd like to address it separately.

@MCGallaspy
Copy link
Contributor Author

I think both the issues you reported stem from the fact that an "upgrade" was attempted on a fresh install. Submitting a patch shortly.

@radinamatic
Copy link
Member

#341 issue opened.

@radinamatic
Copy link
Member

Retested the 0.14.2 on completely new Windows XP VM. Start on boot option selected in the installer does not work with scheduled task run by the NT AUTHORITY\SYSTEM user:

18-01-2016 15-44-18

@MCGallaspy
Copy link
Contributor Author

@radinamatic okay, don't spend too much time on 0.14.2 on XP, I'll see if I can replicate the failure myself. I was able to get 0.14.2 working fine re: start at boot on W7 using a different image. Not sure what my original issue was, but I'll move on for now.

@MCGallaspy
Copy link
Contributor Author

Some updates:

I tried 0.14.2 -> 0.16.0 on W7. I didn't get any errors during installation as you reported, but that still concerns me! Can you try to identify how to replicate that behavior?

That said, I did notice two things:

  1. I enabled the start at boot option, but it didn't work! It seems that (for me) the "Run only when user is logged on" option is enabled by default, which of course fails at system start.
  2. I was also missing video content from the "Learn" page -- the sidebar was blank -- but that's because dev for 0.16.0 isn't yet done! Sorry, I should have warned you, @radinamatic. Unless you experienced a different error? You can at least check the ~/.kalite/content dir to see if the videos are there. I verified on my own test run that they were, so I'm reasonably confident that copying SYSTEM data to user's .kalite dir works reasonably well. :)

Let me try out upgrading from other version -> 0.16.0, then we'll take stock again.

@radinamatic
Copy link
Member

I tried 0.14.2 -> 0.16.0 on W7. I didn't get any errors during installation as you reported, but that still concerns me! Can you try to identify how to replicate that behavior?

After several tryouts the only thing that I can conclude is that it happens only if the server is already running in the background, which is to be expected if the previous 0.14.2 installation is set to start on boot, and user did not expressly stop the server and python processes prior to upgrading to 0.16. When I did that test case (manually stopping the 0.14 server), or when I had 0.14 version which was not set to start on boot, no errors appeared during the upgrade.

@radinamatic
Copy link
Member

And if you have the "Automatically restart the system after errors" checkbox (in Advanced system recovery options) deactivated, you will not even see the error unless you watch carefully the cmd window while it executes the Running setup.py install for ka-lite-static step, as it is really one super-fast flash of command output in red and then the next terminal window appears. Trust me, I tried several times to figure it out, take a screenshot or even snap a photo of it with my camera, but it was always too damn fast... 😠

@radinamatic
Copy link
Member

that's because dev for 0.16.0 isn't yet done! Sorry, I should have warned you, @radinamatic. Unless you experienced a different error?

No worries, I figured a lot of 0.16 core features are still in the re-making. Videos are safely in the ~/.kalite/content folder so I guess we wait for the new 0.16 to finally confirm that it's working.

@MCGallaspy
Copy link
Contributor Author

I did indeed try upgrading while 0.14.2 KA Lite was still running, but my system didn't crash. Also the red text that appears in the cmd prompt during the Running setup.py install for ka-lite-static step is also not an error, just an unfortunately worded message.

Sorry, but I'm not able to replicate the crash -- can you perhaps try to get a VM in a state just prior to the crash, ensure that it happens consistently, and then we'll see about uploading the image somewhere so I can further debug it?

And if you have the "Automatically restart the system after errors" checkbox (in Advanced system recovery options) deactivated

I'm not familiar with this option and I couldn't seem to find docs for it (for W7). Can you describe how to enable/disable it?

@radinamatic
Copy link
Member

Did you also try the upgrade from 0.15 to 0.16? I had the same "logoff" error there too?

Let me fetch a screenshot of that "Automatically restart the system after errors" option.

@radinamatic
Copy link
Member

@MCGallaspy

auto-restart

XP, but it's in the same place on 7 & 8.
It's activated by default when you install Windows - I guess they are too lazy to give a meaningful feedback to the user about what went wrong... 😒

@radinamatic
Copy link
Member

Ok, after several more tryouts, I wasn't able to reproduce it consistently... 😒
The only thing I can say is that it appears when I try to install the upgrade while logged in as a "standard" Windows user, not one with admin rights, and even then maybe only 50% of the times. Maybe it has something to do with my testing machine and not with the installation itself.

The only thing that I can see remaining to try is to download a completely new VM image and make one last upgrade test from 0.14 to 0.16. Will report back after.

@radinamatic
Copy link
Member

@MCGallaspy I'd forget about that error while upgrading on W7 for now, as I couldn't replicate it on a completely new W7 image, a new 0.14.2 install and upgrade to 0.16. Error is there, and even though it doesn't force logoff/restart of the VM, this time I managed to see a bit more of that error terminal output in red and even catch a glimpse of a phrase, something like "folder not available" or "folder not present" at the end... You said that it was an "unfortunately worded message", do you have the exact wording of that message?

@MCGallaspy
Copy link
Contributor Author

You said that it was an "unfortunately worded message", do you have the exact wording of that message?

Yeah, if you check in the Program Files directory where KA Lite is installed, you should find a zipfile called something like ka-lite-static-0.16.0.zip. If you open a command prompt and type the command pip install <filename> with that file as the <filename> you should see the "unfortunately worded message". (You'll probably have to specify the full path to pip, on my system it's C:\Python27\Scripts\pip.exe.)

@radinamatic
Copy link
Member

Ok, this is what I get with what you say above, and it looks pretty tame compared to what I see in that error during install:

C:\Program Files\KA Lite\ka-lite>C:\Python27\Scripts\pip.exe install ka-lite-sta
tic-0.16.0.zip
You are using pip version 7.0.1, however version 8.0.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Processing c:\program files\ka lite\ka-lite\ka-lite-static-0.16.0.zip
  Requirement already satisfied (use --upgrade to upgrade): ka-lite-static==0.16
.0 from file:///C:/Program%20Files/KA%20Lite/ka-lite/ka-lite-static-0.16.0.zip i
n c:\python27\lib\site-packages

C:\Program Files\KA Lite\ka-lite>

The two lines You are using pip version... are yellowish, and all the rest is a normal white on black output. The flash of error output I saw during the installation after the Running setup.py install for ka-lite-static has about 10 lines and is all in bright red letters.

@MCGallaspy
Copy link
Contributor Author

Try running pip uninstall ka-lite-static first, then installing it again -- I'll look closer into possible causes, perhaps I'm thinking of a different issue after all.

@radinamatic
Copy link
Member

Nope, all seems fine here:

C:\Program Files\KA Lite\ka-lite>C:\Python27\Scripts\pip.exe uninstall ka-lite-static
You are using pip version 7.0.1, however version 8.0.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Uninstalling ka-lite-static-0.16.0:
  c:\python27\lib\site-packages\ka_lite_static-0.16.0-py2.7.egg-info
  c:\python27\lib\site-packages\kalite
Proceed (y/n)? y
  Successfully uninstalled ka-lite-static-0.16.0

C:\Program Files\KA Lite\ka-lite>C:\Python27\Scripts\pip.exe install ka-lite-static-0.16.0.zip
You are using pip version 7.0.1, however version 8.0.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Processing c:\program files\ka lite\ka-lite\ka-lite-static-0.16.0.zip
Installing collected packages: ka-lite-static
  Running setup.py install for ka-lite-static
Successfully installed ka-lite-static-0.16.0

C:\Program Files\KA Lite\ka-lite>

I tried the above with the server running in the background, and logged in as both admin Windows user and standard one with no admin rights, since it was there that the error occasionally appeared, but no dice... Maybe we should set this aside unless it starts raising its nasty head in a more consistent manner.

@MCGallaspy
Copy link
Contributor Author

Okay, at this time I've managed to upgrade from 0.13 and 0.14 to 0.16 with apparent success inasmuch as this PR is concerned, meaning that:

  • SYSTEM's profile is migrated to the installing user's profile if it exists (videos + user data)
  • Changing options using the task-tray program no longer causes CONFIG.dat related errors.

@radinamatic you still have quite a few unaddressed bugs, which I'll try to summarize shortly below. Additionally, I've also encountered at least one apparent application error from upgrading 0.13 -> 0.16, which I'll file elsewhere.

That said, I think if we set the bar for this PR to addressing the above points, then we can call it a success and consider the other bugs separately.

@MCGallaspy
Copy link
Contributor Author

Additionally, it seems we must ensure the start-at-boot scheduled task is set to run whether the user is logged in or not (at least on Windows 7).

@radinamatic
Copy link
Member

Ok, will re-testing if start-at-boot scheduled task executes correctly whether the user is logged in or not on Win 7/8. I think that so far it did work on 7, but I can't recall for Win 8.

@MCGallaspy
Copy link
Contributor Author

We can tackle start at boot separately -- I just wanted to note it down. I would like specifically to test whether user data + content is migrated from the prior location to the user's .kalite dir, and that the task-tray config options work without error in 0.16. But looking more closely at the thread, it seems you already confirmed this for 0.12 and 0.15, yes? And I independently verified it for 0.13 and 0.14. If my understanding is correct, I think we should consider the other issues separately, as this thread is getting unwieldy.

@radinamatic
Copy link
Member

Yes, user data + content is seemingly migrated from the prior location to the user's .kalite dir, and I haven't seen any task-tray config errors with installer # 104 in any upgrade scenarios. I say "seemingly" because videos and langpacks are there in the migrated .kalite dir, but are not functional with this installer. As soon this is solved we can definitely confirm that migration is, indeed, successful.

And yes, we should start considering other issues separately, this discussion is getting too long to manage... 😉

@MCGallaspy
Copy link
Contributor Author

As soon this is solved we can definitely confirm that migration is, indeed, successful.

It won't be resolved in this PR, it's an application issue.

And yes, we should start considering other issues separately, this discussion is getting too long to manage...

Agreed, I'll open separate issues and close this one once I get someone to review it.

@MCGallaspy
Copy link
Contributor Author

@rtibbles consider this a last effort to get a reviewer -- if you're not able or willing in the next few days, could you kindly just press the "merge" button for me?

@MCGallaspy
Copy link
Contributor Author

@radinamatic
Copy link
Member

Yes, that about covers it, #346 is about same as my #345...?

MCGallaspy added a commit that referenced this pull request Jan 27, 2016
[Windows] Change CONFIG.dat file location, behavior
@MCGallaspy MCGallaspy merged commit 9021633 into learningequality:develop Jan 27, 2016
@MCGallaspy MCGallaspy removed the has PR label Jan 27, 2016
@MCGallaspy
Copy link
Contributor Author

Note to self: update build server installers branch to build from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants