Skip to content
Merged
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
46 changes: 36 additions & 10 deletions BlocklyLogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# Constants
PLATFORM_MACOS = 'darwin'
PLATFORM_WINDOWS = 'win32'

path = None

Expand Down Expand Up @@ -40,6 +41,8 @@ def emit(self, record):
else:
# Set the module-level path
path = logfile_name
elif platform == PLATFORM_WINDOWS:
logfile_name = __set_windows_logpath(filename)

# Create a logger
logger = logging.getLogger('blockly')
Expand Down Expand Up @@ -77,11 +80,11 @@ def __set_macos_logpath(filename):

# Does the log directory exist
try:
result = __verify_macos_logpath(log_path)
if result is None and __create_macos_logpath(log_path) is None:
# Try to create the directory
result = __verify_logpath(log_path)
if result is None and __create_logpath(log_path) is None:
# Try to create the directory in the tmp directory
log_path = '/tmp'
result = __verify_macos_logpath(log_path)
result = __verify_logpath(log_path)
if result is None:
return 1

Expand All @@ -90,19 +93,42 @@ def __set_macos_logpath(filename):
return 2


def __verify_macos_logpath(file_path):
def __set_windows_logpath(filename):
user_home = os.path.expanduser('~')
log_path = user_home + '/AppData/Parallax'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zfi - I failed to notice this when scanning the code, but I see the effects of it in my build and test... It accidentally creates the Parallax subfolder inside the /AppData folder instead of inside the /AppData/Local folder.

image

When run, the /AppData/Parallax folder is empty (no log file appeared). I don't know if this is because the system somehow let the app create the folder but won't let it populate it, or not.

Copy link

@PropGit PropGit Feb 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: Retesting shows that the Log File field is blank. So, the plan b to store it in the user's home folder didn't work either?

image


# Does the log directory exist
try:
info = os.stat(file_path)
return info
result = __verify_logpath(log_path)

if result is None and __create_logpath(log_path) is None:
# try to create the log file in the user's home directory
log_path = user_home
result = __verify_logpath(log_path)

if result is None:
return 1

return log_path + '/' + filename
except OSError:
return 2


# Create a file path for the log file
def __create_logpath(file_path):
try:
os.makedirs(file_path)
return path
except OSError as ex:
print ex.message
return None


def __create_macos_logpath(file_path):
# Verify that the file for the log file exists
def __verify_logpath(file_path):
try:
os.makedirs(file_path)
return path
info = os.stat(file_path)
return info
except OSError as ex:
print ex.message
return None