Related custom theming OF OPEN EDX - linux

i am using devstack hawthorn problem i am facing is , i created a folder parallel to open-edx project where i cloned it. folder structure i created is edx/app/edxapp/edx-platform/themes/my-theme inside my-theme lms and cms is there and further static files in both and i put o studio-logo.png in cms images folder to check custom theme is working or not and in studio-shell cmd edx/etc directory opened studio.yml and changed variable
COMPREHENSIVE_THEME_DIRS: [
“/edx/app/edxapp/edx-platform/themes”
]
ENABLE_COMPREHENSIVE_THEMING: true
DEFAULT_SITE_THEME: “my-theme”
and run cmd paver update_assets
’
Build failed running pavelib.assets.update_assets: Subprocess return code: 1’
please help#BbrSofiane or please tell i created wrong structure or file inside cms and lms not correctenter image description here

Related

how to avoid mixture of \ and / in file paths when joining paths in Docker containerized Python code

As far as I'm aware I'm using best practices to define paths (using raw strings) and how I go about joining them (using os.path.join()), e.g.
import os
fdir = r'C:\Code\...\samples'
fpath = os.path.join(fdir, 'fname.ext')
and doing so has not caused me any problems when running my code within a Python or command shell. If I print fpath to the console I get consistent use of \s in the path:
C:\Code...\samples\fname.ext
But when I run a Docker containerized version of the code and run the image I get the error:
FileNotFoundError: [Errno 2] No such file or directory:
'C:\Code\...\samples/fname.ext'
I don't understand why os.path.join() has used a / to join fdir and fname.ext when the rest of the path included \\. It doesn't do this when I run the code outside of the container.
I have tried using os.path.normpath():
fpath = os.path.join(fdir, 'fname.ext')
fpath = os.path.normpath(fpath)
as discussed here, and os.sep.join():
fpath = os.sep.join([fdir, 'fname.ext'])
as covered here, and Path().joinpath():
from pathlib import Path
fpath = Path(fdir).joinpath('fname.ext')
as well as Path() / 'path_to_add':
fpath = Path(fdir) / 'fname.ext'
as discussed here, but in every case I end up with the same result using os.path.join().
Can someone please help me to understand what is going on and how to create consistent paths that will work whether I run the code in Python in a Windows environment, or in a Docker container?
Update Nov. 16:
In trying to keep my question brief I think I've left out details that are crucial. Apologies to those who have kindly taken the time to offer suggestions based on my incomplete description of the problem.
My code needs to import/export files from/to directories that are defined within a user-specified configuration file.
So the configuration file has a section of code where the user defines variables and paths, e.g.
samplesDir = r"path-to-samples-directory"
The variables are stored in a dictionary of dictionaris and stored as a .json.
At the start of the code the user defines the key that selects the dictionary of interest so that at various parts in my code when a file needs to be imported/exported, the paths are at hand.
So back to my example, samplesDir is stored in the configuration dictionary, cfgDict, so all I need to do is append the file name:
sampleFpath = os.path.join(sampleDir, sampleFname)
and sampleFname is determined based on other variables.
Because of the dynamic nature of the variables (including directory paths and file paths), I think it rules out the use of static path defined in a .yml with Docker Compose.
Update Nov. 18:
It may help to include a few more details and some screenshots.
The above screenshot shows the file and folder structure of the src directory containing the source code, the main app.py script for command-line use, the Dockerfile, etc.
The configs folder contains JSON files that includes variables, paths to directories and files. The user can create configuration files either by copying an existing one and modifying the entries, or configuration files can be generated by calling config.py.
Within config.py I have pre-set variables and paths, so that the directory path to the configuration files (configs), sample files (sample_DROs) and others (e.g. fiducials) are all within src.
I don't anticipate any reason why the user would want to store the config files anywhere else, nor do I expect them to want to use different sample files (or move them elsewhere). However, they will undoubtedly create their own fiducials and may decide not to store them in the fiducials directory (i.e. somewhere not within the src directory).
Likewise I have pre-set the download directory (based on the parameters stored within the configuration files, files are fetched from a server and downloaded) to be the default Downloads directory:
rootDownloadDir = os.path.join(Path.home(), "Downloads", "xnat_downloads")
Those files are later imported, processed, and the outputs are (by default) exported into sub-directories within rootDownloadDir.
Within Dockerfile I set the working directory of the container to be that of the source code and copy all of the contents of src (with the exception of some directories defined in .dockerignore):
WORKDIR C:/Code/WP1.3_multiple_modalities/src
...
COPY . .
so that the structure of the container mimics that of WORKDIR:
Hence I have allowed for flexibility in import/export directories, and they are by default a combination of paths within and outside of the src directory. And so, the code executed within the container will need to access files both within and outside of src.
That said, I don't know what rootDownloadDir will look like when os.path.join(Path.home(), "Downloads", "xnat_downloads") is run within the container.
This has got me thinking - Is it bad practice to set the download directory outside of src?
Returning to the original error:
the sample file is in the container:
From the actual behavior I can suppose that the container is based on Unix-like image. Path separator is / in such systems.
To build an environment-independent path which works inside and outside of the container you need the following steps:
Mounting of host folder to container directory.
Environment variable inside and outside the container.
I can show an example of how this is achievable via docker-compose tool and its configuration file docker-compose.yml:
# docker-compose.yml file
version: '3'
services:
<service_name>: # your service name here
image: <image_name> # name of image your container is built on
environment:
- SAMPLES_PATH=/samples
volumes:
- C:\Code\somepath\samples:/samples
In your python code you can use the following structure:
import os
fdir = os.getenv('SAMPLES_PATH', r'C:\Code\...\samples')
fpath = os.path.join(fdir, 'fname.ext')

java.io.FileNotFoundException: Resource not found: /credentials.json on Java QuickStart for Classroom API

I have implemented the Java QuickStart for the Classroom API and am getting an error message "java.io.FileNotFoundException: Resource not found: /credentials.json" at run-time. I copied my credentials.json file to the Project res directory, but continue to get this error. Any suggestions?
I tried it in a different way than I found on other websites, and it worked for me.
replace below code:
InputStream in = GoogleSheetAPIHandler.class.getClass().getResourceAsStream(CREDENTIALS_FILE_PATH);
With this code:
InputStream in = new FileInputStream(CREDENTIALS_FILE_PATH);
You need to import credential.json file into the src/main/resources folder in eclipse. You may be included in the project folder. But you need to import it into eclipse.
locate your credentials.json file in the folder.
click and drag it
drop it in src/main/resource and click ok.
After importing into eclipse it should show like the below image.
There are two steps needed to find the resource in Eclipse:
To have the file in the resources folder
Create the resource folder (if it does not exist): src/main/resouces
Add the credential file to the resource folder: src/main/resouces/credential.json
To have the resources folder in the Source Java Build Path
Go to Eclipse Path Source: Project > Properties > Java Build Path > Source (tab)
Add resources folder: Add Folder ... (button) > resources (check box) > OK (button)
https://stackoverflow.com/a/46950488/10850340
The name of your file has to be credentials only, if you have credentials.json as the name of your file in your folder you will get this error.

Creating A Folder In the Temp Folder

I'm trying to create a folder within the temp folder that doesn't have a random name.
Here is how I was trying to create the folder within the temp folder.
if not DirExists(ExpandConstant('{%tmp}\Utilities\SDK')) then
CreateDir(ExpandConstant('{%tmp}\Utilities\SDK'));
Log('Temp\Utilities\SDK Folder Has Been Created.');
I had a look at this thread, but even with the %, unfortunately, it still doesn't create the folder.The script compiles and runs as expected, however the folder doesn't create even though it says it has in the log file, I understand that the log file will say that because its told too, however, if the folder was unable to be created, wouldnt it crash? or return a false if an if statement was present?
With CreateDir() You must create dirs one after the other and not a dir structure at once.
if not DirExists(ExpandConstant('{tmp}\Utilities')) then
CreateDir(ExpandConstant('{tmp}\Utilities'));
if not DirExists(ExpandConstant('{tmp}\Utilities\SDK')) then
CreateDir(ExpandConstant('{tmp}\Utilities\SDK'));
if DirExists(ExpandConstant('{tmp}\Utilities\SDK')) then
Log('Temp\Utilities\SDK Folder Has Been Created.') else
Log('Temp\Utilities\SDK Folder ERROR : NOT Created.');
Inno Setup has a function to create a dir structure at once
function ForceDirectories(Dir: string): Boolean;
Example:
if not DirExists(ExpandConstant('{tmp}\Utilities\SDK')) then
ForceDirectories(ExpandConstant('{tmp}\Utilities\SDK'));
Also keep in mind :
{tmp} all is related to the Inno Setup Temp folder is-XXXXX.tmp
C:\Users\...\AppData\Local\Temp\is-XXXXX.tmp
{%temp} is the users Temp folder
C:\Users\...\AppData\Local\Temp
I think you want the Windows Temp and not the tmp from InnoSetup
{tmp}:
Temporary directory used by Setup or Uninstall. This is not the value of the user's TEMP environment variable. It is a subdirectory of the user's temporary directory which is created by Setup or Uninstall at startup (with a name like "C:\WINDOWS\TEMP\IS-xxxxx.tmp"). All files and subdirectories in this directory are deleted when Setup or Uninstall exits. During Setup, this is primarily useful for extracting files that are to be executed in the [Run] section but aren't needed after the installation.
So I think you want to do somethink like this:
if not DirExists(ExpandConstant('{%temp}\Utilities\SDK')) then
CreateDir(ExpandConstant('{%temp}\Utilities\SDK'));
Log('Temp\Utilities\SDK Folder Has Been Created.');

Veracode through an error - ASPCONFIG: Could not autodiscover 'components.config'

I have a Veracode plugin in my VS 2013 Professional.
I have ucommerce.dll, Sitecore.Kernel and Sitecore.Analytics.dll
I set copy local true for all above dll files.
When i tried to pre-compile all the web project I'm getting a below error message
1>------ Pre-compile started: Project: XXXXX.Web.PQRPorta\ ------
1>Pre-compiling with command similar to the following:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -p
"C:/XXXXX.Web.PQRPortal" -v "XXXXX.Web.PQRPortal/" -fixednames -f -c
-d "C:/SVN/trunk/Releases/SourceCode/Source/PrecompiledWeb/XXXXX.Web.PQRPortal"
1>error ASPCONFIG: Could not autodiscover 'components.config'. Make
sure it's present in the application folder
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\' or in a
sub folder. Paths ignored
''C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\bin',
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\App_Data',
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\obj''
1>XXXXX.Web.PQRPortal\ - 1 error, 0 warnings
Is there any configuration missing?
Update
I found the components.config file inside
C:\inetpub\wwwroot\XXXX\Website\sitecore modules\Shell\uCommerce\Configuration
and I added the file inside the web project root directory and tried to precompile web project, now I’m getting different error error
ASPRUNTIME: Type is not resolved for member 'Castle.Windsor.Configuration.Interpreters.ConfigurationProcessingException,Cast‌​le.Windsor, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc'.
any solution for it?
The components.config is a file uCommerce need.
The configuration file should be placed somewhere below the uCommerce folder. (not sure where depend on the version) It will automatically be picked up when the application starts up.

Java.nio.Files "createSymbolicLink" erases target dir contents?

I want to create a link from my webapp to a directory on the server.
I'm using the following code:
java.nio.file.Path link = Paths.get(dirInMyApp);
java.nio.file.Path target = Paths.get(dirOnTheServer);
Files.createSymbolicLink(link, target);
This works, but seems to have a strange side effect: If "dirOnTheServer" had files in it, it will be empty after the link is created!
Also, I can use the link from my app and add files to the "dirOnTheServer" directory, but if I redeploy my app, it's empty again.
Actually createSymbolicLink does not empty the directory - undeploying a webapp from tomcat with such links will.
This can be prevented by deleting the link when the webapp is being undeployed.

Resources