VrrtepCLI

Started by Tirea Aean, May 22, 2011, 03:40:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tirea Aean

sourcecode website as posted in post 1 updated. Let the downloading and bug reporting begin. >:D

Sіr. Ηaxalot

May I suggest installing it in %APPDATA% or %PROGRAMFILES%, depending on if it's supposed to be visible to the user or not? I consider putting data/applications directly in the user directory as a bit of an ugly hack.

Tirea Aean

#22
Perhaps in Windows it is. On linux apparently it is not uncommon for a program to make a hidden file in the home directory. Though I see your point. the convention for Windows is generally to install everything to \Program Files\

EDIT: Oh. yeah, the stuff in that file don't need to be visible to the user after installation. Perhaps some tweaks to the windows versions to install everything to %APPDATA% is in order.

Swoka Ikran

#23
Quote from: Tirea Aean on May 23, 2011, 01:31:54 AM
Perhaps in Windows it is. On linux apparently it is not uncommon for a program to make a hidden file in the home directory. Though I see your point. the convention for Windows is generally to install everything to \Program Files\

EDIT: Oh. yeah, the stuff in that file don't need to be visible to the user after installation. Perhaps some tweaks to the windows versions to install everything to %APPDATA% is in order.
Well...I thought I was going to bed, but now I'm watching Mythbusters...

Anyway, the reason I originally put the app in %userprofile%\.vrrtepcli on Windows is because doing this means it works on both Linux and Windows without requiring any changes. Using different folders requires OS and folder detection code.

I'll look at it tomorrow.
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Sіr. Ηaxalot

Quote from: Swoka Ikran on May 23, 2011, 02:00:19 AM
Quote from: Tirea Aean on May 23, 2011, 01:31:54 AM
Perhaps in Windows it is. On linux apparently it is not uncommon for a program to make a hidden file in the home directory. Though I see your point. the convention for Windows is generally to install everything to \Program Files\

EDIT: Oh. yeah, the stuff in that file don't need to be visible to the user after installation. Perhaps some tweaks to the windows versions to install everything to %APPDATA% is in order.
Well...I thought I was going to bed, but now I'm watching Mythbusters...

Anyway, the reason I originally put the app in %userprofile%\.vrrtepcli on Windows is because doing this means it works on both Linux and Windows without requiring any changes. Using different folders requires OS and folder detection code.

I'll look at it tomorrow.


The thing is that the dot doesn't hide the folder in Windows and I thought that since the use of %userprofile% only applies for the windows version anyway, it wouldn't be much of a problem to change?

Swoka Ikran

Quote from: Sir. Haxalot on May 23, 2011, 06:32:41 AM
The thing is that the dot doesn't hide the folder in Windows and I thought that since the use of %userprofile% only applies for the windows version anyway, it wouldn't be much of a problem to change?
VrrtepCLI references its resource files by absolute path right now:
os.path.expanduser('~')+"/.vrrtepcli/metaWords.txt"

I've found a way to make it not care about location: os.path.expanduser() could possibly be replaced with sys.path[0], but I need someone on Linux to verify sys.path[0] works (because some places say yes, others say no).

Can someone run this on Linux or Mac please? I need to see if sys.path[0] works on it. Copy and save it as a .py (anywhere you like), then run from terminal.

#!/usr/bin/python
import sys
print sys.path[0]

You should get the folder where the script is located as the output. If you don't...not good.

Also, just as an aside: A lot of other cross-platform programs also use %userprofile%\.appname folders for data on Windows, so, IMO, using %userprofile%\.vrrtepcli isn't that big of a deal.
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Tirea Aean

sys.path[0] on linux is the empty string.


Swoka Ikran

Quote from: Tirea Aean on May 23, 2011, 02:07:36 PM
sys.path[0] on linux is the empty string.


You ran Python interactively...it's supposed to be empty in that case. It is on Windows too.

Can you save the print command to a .py then run it from the command line (e.g. python test.py), rutxe?
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Tirea Aean

#28
oh right. should have seen that coming. /me facepalms

tirea@ean:~$ ./test.py
/home/tirea


it works.



Swoka Ikran

Quote from: Tirea Aean on May 23, 2011, 02:24:47 PM
oh right. should have seen that coming. /me facepalms

tirea@ean:~$ ./test.py
/home/tirea


it works.
Cool. I'll go through the app and make the change...

Do you want me to modify the Windows install script to put it in %Appdata%? Only difference will be that users will need to type: cd "%appdata%\.vrrtepcli" instead of the current cd "%userprofile%\.vrrtepcli" when they open CMD.
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Tirea Aean

is there a way so that all they have to do is open cmd and use it?

(like you can on linux because the install script makes an alias)

Kä'eng

Instead of requiring installation into some specific directory, how about using python's __file__ variable (gives the path to the current script) so the user can just unzip the program wherever he/she wants?

(Note that installing in "%USERPROFILE%" or "%APPDATA%" is a common thing for Windows malware to do when it has not obtained administrator access yet, so doing so may trigger false positives from antivirus software)
Ma evi, ke'u ke lu prrte' to fwa sim tuteot ayawne.
Slä txo tuteo fmi 'ivampi ngat ro seng, fu nìfya'o, a 'eykefu ngati vä', tsakem ke lu sìltsan.
Tsaw lu ngeyä tokx! Kawtu ke tsun nìmuiä 'ivampi ngat txo ngal ke new tsakemit.
Ha kempe si nga? Nì'awve, nga plltxe san kehe. Tsakrr, ngal tsatsengti hum!

Swoka Ikran

Quote from: Tirea Aean on May 23, 2011, 02:53:19 PM
is there a way so that all they have to do is open cmd and use it?

(like you can on linux because the install script makes an alias)
Put it in your path. Same procedure as you did with Python, but put the vrrtepCLI folder instead of the Python folder. Aliases don't exist on Windows.

I made the sys.path[0] change...it works if I use the .py version, but is incompatible with py2exe, so if we keep this change, we can't have an EXE version :( What do we want to do about this?

Quote from: Kä'eng on May 23, 2011, 02:59:34 PM
Instead of requiring installation into some specific directory, how about using python's __file__ variable (gives the path to the current script) so the user can just unzip the program wherever he/she wants?

(Note that installing in "%USERPROFILE%" or "%APPDATA%" is a common thing for Windows malware to do when it has not obtained administrator access yet, so doing so may trigger false positives from antivirus software)
__file__ won't work. :( That was the first thing I tried. I need an absolute path to the script folder, not a relative path to the script itself (which is what __FILE__ gives on Windows). Sys.path[0] does exactly what I need, but doesn't work if the program is compiled.

Also, the malware thing...non-issue. Google Chrome, Minecraft, and Virtual Box (3 big name programs), all install to %APPDATA% and %USERPROFILE%. GIMP keeps a couple things in there as well...
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Sіr. Ηaxalot

Quote from: Tirea Aean on May 23, 2011, 02:53:19 PM
is there a way so that all they have to do is open cmd and use it?

(like you can on linux because the install script makes an alias)

The best way would ba changing the PATH variable to include the application directory. Or the mory ugly way; putting binaries in C:\Windows\system32

Swoka Ikran

Quote from: Sir. Haxalot on May 23, 2011, 03:27:10 PM
Quote from: Tirea Aean on May 23, 2011, 02:53:19 PM
is there a way so that all they have to do is open cmd and use it?

(like you can on linux because the install script makes an alias)

The best way would ba changing the PATH variable to include the application directory.
Not easily doable in a batch script. If I do: set PATH=%path%;%userprofile%\.vrrtepcli it's only good until the batch script ends. You have to edit the registry or change it in System Properties if you want to make it permanent.

Quote from: Sir. Haxalot on May 23, 2011, 03:27:10 PM
Or the mory ugly way; putting binaries in C:\Windows\system32
That's one way to do it...
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Tirea Aean

my only concern is, not every windows user is tech-savvy. The easiest way possible for the end user is my goal.

Swoka Ikran

Quote from: Tirea Aean on May 23, 2011, 03:53:57 PM
my only concern is, not every windows user is tech-savvy. The easiest way possible for the end user is my goal.
The system32 method is easiest then.

As for the sys.path[0] and putting it in %appdata% thing, I'm just going to forget it since Py2EXE isn't compatible with it. IMO, having a standalone EXE version is far more important to users than being able to move the .py version around.

I'll add the path support so you can use it by just opening CMD and typing vrrtepcli :)
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Kä'eng

#37
Quote from: Swoka Ikran on May 23, 2011, 03:22:56 PM
Quote from: Kä'eng on May 23, 2011, 02:59:34 PM
Instead of requiring installation into some specific directory, how about using python's __file__ variable (gives the path to the current script) so the user can just unzip the program wherever he/she wants?
__file__ won't work. :( That was the first thing I tried. I need an absolute path to the script folder, not a relative path to the script itself (which is what __FILE__ gives on Windows). Sys.path[0] does exactly what I need, but doesn't work if the program is compiled.
It works for me to just replace all instances of
os.path.expanduser('~')+"/.vrrtepcli/<filename>"
with
os.path.join(os.path.dirname(__file__), "<filename>")

Edit:
Quote from: Tirea Aean on May 23, 2011, 03:53:57 PM
my only concern is, not every windows user is tech-savvy. The easiest way possible for the end user is my goal.
I'd say the easiest way for the end user is that they can just double-click the .exe/.cmd/.py/whatever (or create a shortcut to it on their desktop :)), and not have to open a command prompt at all.
Ma evi, ke'u ke lu prrte' to fwa sim tuteot ayawne.
Slä txo tuteo fmi 'ivampi ngat ro seng, fu nìfya'o, a 'eykefu ngati vä', tsakem ke lu sìltsan.
Tsaw lu ngeyä tokx! Kawtu ke tsun nìmuiä 'ivampi ngat txo ngal ke new tsakemit.
Ha kempe si nga? Nì'awve, nga plltxe san kehe. Tsakrr, ngal tsatsengti hum!

Swoka Ikran

#38
Quote from: Kä'eng on May 23, 2011, 04:20:58 PM
It works for me to just replace all instances of
os.path.expanduser('~')+"/.vrrtepcli/<filename>"
with
os.path.join(os.path.dirname(__file__), "<filename>")

I didn't use os.path.join/os.path.dirname...I just tried __FILE__+"/FILENAME". I'll give your method a shot. :)

Anyone know if Py2EXE will work with __FILE__? It doesn't with sys.path[0]...

EDIT: __FILE__ works in the .py version :) , but Py2EXE won't work with __FILE__. :( NameError: name '__FILE__' is not defined when I run the compiled EXE.
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Kä'eng

#39
It has to be lower case: "__file__", not "__FILE__"

Another possibility is to use sys.argv[0], which should work even in py2exe. That's the path to the main script, not to the current module, but as long as they're all in the same directory it'll work fine.
Ma evi, ke'u ke lu prrte' to fwa sim tuteot ayawne.
Slä txo tuteo fmi 'ivampi ngat ro seng, fu nìfya'o, a 'eykefu ngati vä', tsakem ke lu sìltsan.
Tsaw lu ngeyä tokx! Kawtu ke tsun nìmuiä 'ivampi ngat txo ngal ke new tsakemit.
Ha kempe si nga? Nì'awve, nga plltxe san kehe. Tsakrr, ngal tsatsengti hum!