I'd like to create a Python project using Azure Functions. When creating, files are allocated into the default layout (as recommended in documentation), so currently my project has the following structure:
root
| - function_1
| | - __init__.py
| | - function.json
| - function_2
| | - __init__.py
| | - function.json
| - function_N
| | - __init__.py
| | - function.json
| - src
| | - __init__.py
| | - logic
| - host.json
| - local.settings.json
| - requirements.txt
| - tests
The problem is that N might be relatively big (>=10), so in this way the project will become messy very quickly. I'd like the project to be of the following format, with functions being grouped into folders (eg for versioning purpose and just to keep them separately from the code):
root
| - v0
| | - function_1
| | | - __init__.py
| | | - function.json
| | - function_N
| | | - __init__.py
| | | - function.json
| - v1
| | - function_1
| | | - __init__.py
| | | - function.json
| | - function_M
| | | - __init__.py
| | | - function.json
| - src
| | - __init__.py
| | - logic
| - host.json
| - local.settings.json
| - requirements.txt
| - tests
or something close to it, the main aim is to separate functions into separate folders.
However when I'm trying to run a project with such a layout, I get message saying that "No job functions found", or "Unable to find project root. Expecting to find one of host.json, local.settings.json in project root.", if I move host.json to functions folder.
Is there a way to configure project to work with this custom layout, so that functions are discoverable from their grouping directories?
All my functions are HttpTriggers.
I'm using Python3.9.7 and Visual Studio Code Version: 1.63.2 with Azure Functions extension for Visual Studio Code v1.6.0
One of the workaround I did to change the folder structure of the Azure Functions project is:
- Created the Azure Functions Project of1 Http Trigger and 1 Queue Trigger in a separate folder called QueueTriggerFuncs.
- When I Published this Azure Functions Project, got the same default folder structure shown in Microsoft documentation.
- I tried to create a folder manually in the wwwroot folder but it gave me an error called:
409 Conflict: Cannot delete directory. It is either not empty or access is not allowed. in Azure kudu
So, While publishing the project I unchecked the Run from package setting in Visual Studio Publish Profile:
And then published to Azure Function App.
- Going to Kudu Console (CMD) - seen the same folder structure but this time I'm able to create the folders manually without any error.
- Created the new folder as QueueTriggerFuncs.
- Used this command to move my Queue Trigger Functions to the the specific folder created.
mv FunctionsQ QueueTriggerFuncs
its kind of format
mv FunctionFolderName DestinationFolderName
And Now this is the modified folder structure as expected:
Where my QueueTriggerFuncs Folder contains only specific functions like Queue Trigger related functions.
Related
I am writing a simple file server to upload and download files with express#4.18.2, and Im stuck on the download part. Whenever I try to download a file that has no name, but only an extension (like .gitignore or .prettierrc) with res.download, I get a NotFoundError (see full error message below).
Example:
app.get("/download", function (req: Request, res: Response) {
res.download("C:/Users/stadl/Desktop/File-Server/.gitignore");
});
results in a NotFoundError, however, the following works:
app.get("/download", function (req: Request, res: Response) {
res.download("C:/Users/stadl/Desktop/File-Server/t.txt");
});
The file paths are both correct, and both files are existing, the directory structure looks like that:
C:/Users/stadl/Desktop/File-Server/
|
|
| - - - client/
| - - - server/
| |
| | - - - server.ts (contains the app.get("/download")... snippet)
| . . .
|
| - - - .gitignore
| - - - t.txt
|
. . .
The same happens with relative paths, (../.gitignore and ../t.txt).
Is this a bug, is this intended or am I doing something wrong?
You need to allow dotfiles in the options object of res.download by setting allow, since it's disabled/ignored by default (the default value ignore sends 404):
res.download("C:/Users/stadl/Desktop/File-Server/.gitignore", {dotfiles:"allow"});
see:
dotfiles
Option for serving dotfiles. Possible values are “allow”,
“deny”, “ignore”.
https://expressjs.com/en/5x/api.html#res.download
and
dotfiles
Possible values for this option are:
“allow” - No special treatment for dotfiles.
“deny” - Deny a request for a dotfile, respond with 403, then call next().
“ignore” - Act as if the dotfile does not exist, respond with 404, then call next().
https://expressjs.com/en/5x/api.html#express.static
I'm generating a PDF document from asciidoc with asciidoctor-web-pdf. So far most tasks work fine.
asciidoctor-web-pdf -a stylesheet="asciidoctor-pdf/css/asciidoctor.css,asciidoctor-pdf/css/document.css,assets/pdf-export/custom.css" \
-a stem \
--require asciidoctor-kroki \
docs/modules/ROOT/pdf.adoc
But my document does not include images or generated diagrams (plantuml).
The folder structure follows the layout of Antora because I mainly use Antora. The PDF is just a necessary side-product.
My folder structure looks like this (as said antora-layout):
project-folder
+ docs
| + modules
| | + ROOT
| | | + assets
| | | | + images
| | | | | - logo.png
| | | + pages
| | | | - index.adoc
| | | | - 01-intro.adoc
| | | | - some-other.adoc
| | | - nav.adoc
| | | - pdf.adoc
The pdf.adoc is just a list of includes to make sure every needed adoc file is part of the PDF.
According to the folder structure the correct path to my logo.png is docs/modules/ROOT/assets/images/logo.png (or absolute /home/sebastian/work/workspace/workspace-p/jira-ops-manual/docs/modules/ROOT/assets/images/logo.png).
When I generate the PDf with above command I get these errors:
normal image
Failed to load resource: net::ERR_FILE_NOT_FOUND at file:///home/sebastian/work/workspace/workspace-provinzial/jira-ops-manual/docs/modules/ROOT/logo-provinzial.png:1
plantuml diagram
asciidoctor: ERROR: pages/04-system-setup/index.adoc: line 8: include file not found: /home/sebastian/work/workspace/workspace-provinzial/jira-ops-manual/docs/modules/ROOT/pages/04-system-setup/image$04-system-setup/system-overview.puml
I guess the problem is that asciidoctor-web-pdf doesn't subsitute the image$... part of the path so the reference is wrong (or in general cannot resolve these references). Images and diagrams are embedded like this:
image::logo.png[Logo, align="center"]
[plantuml, system-overview-plantuml-image, svg]
----
include::image$04-system-setup/system-overview.puml[]
----
Does anyone have a hint how to solve my issue? I'm open to other solutions as well. Maybe there is a simpler way with antora so I don't need asciidoctor-web-pdf at all?
EDIT: I solved the problem with normal images by setting the images path at the top of the pdf-adoc.
= Operations Manual
:imagesdir: ./assets/images
include::pages/index.adoc[]
include::page1.adoc[]
include::page2.adoc[]
...
But the problem with the plantuml images still exists.
:imagesdir: ./assets/images
First, I would write a comment but I haven't 50 reputations - So I answer… sort of:
You have to know asciidoc-web-pdf is still under active development and I can't imagine it isn't well tested beside Antora. In this discussion you'll get some insights:
https://discuss.asciidoctor.org/Single-PDF-and-multiple-HTML-from-same-sources-td7640.html
That being said, I would reduce complexity (build my stuff out if Antora) and start building in little steps. Then succeed to the next step.
I want to zip just a file in Python which present in a folder. I am finding hard to create zip file with the below code snippet. It does create zip file, but it has complete folder structure inside.
import zipfile as zip
root=r"C:\XXXX\YYYYYY\ZZZZ\"
file="abc.txt"
zipper=zip.ZipFile(file=os.path.join(root,file.replace("txt","zip")),mode="w",compression=zip.ZIP_DEFLATED)
zipper.write(os.path.join(root,file))
zipper.close()
Actual output:
#################
abc.zip
|
XXXX - Folder
|
YYYYYY - Folder
|
ZZZZ - Folder
|
abc.txt
Expected output
###############
abc.zip
|
abc.txt
One way I learnt and working is :
os.chdir(root)
To set the working directory to the folder where the files are present. Then, pass just the filename instead of complete path to create zip.
Not sure, if it is the correct and best way.
As I know, non-Python files (i.e. file.sublime-menu, file.sublime-keymap, etc.) can be located at ANY level inside package directory:
Will be loaded? (Yes/No)
Packages
|-- Foo Package
| |-- Old version
| | |-- foo.sublime-menu Y - it is the problem
| | |-- foo.sublime-keymap Y - it is the problem
| | |-- foo.py N
| |
| |-- foo.sublime-menu Y
| |-- foo.sublime-keymap Y
| |-- foo.py Y
I want to have Old version directory inside Foo Package, but the problem is that old menu and keymap files will be loaded. Is there a way to have some special file (call it package.exclude for example) with exclusion rules? Something like
exclude:
./Old version
Other than changing the extension of the file to not be one that Sublime recognizes and loads, there is no way to stop it from finding and loading resources short of removing the file entirely or adding the package that they're stored in into the ignored_packages setting.
I have a patch file that I want to install in linux. I know there is a patch command, And I tried to use it like this:
patch -i file --verbose
where file is the patch file. But it asks me for the file to be patched(to be changed):
Hmm... Looks like a unified diff to me...
can't find file to patch at input line 17
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|From 13fac179aa50556ba3c60790a9beb6ca9d0b1b8b Mon Sep 17 00:00:00 2001
|From: Andrey Vagin <avagin#openvz.org>
|Date: Fri, 28 Jan 2011 23:31:20 +0300
|Subject: [PATCH rh5] vdso: export vdso_sysctl_vsyscall
|
|Signed-off-by: Andrey Vagin <avagin#openvz.org>
|---
| arch/x86_64/vdso/vclock_gettime.c | 4 ++--
| arch/x86_64/vdso/vextern.h | 1 +
| include/asm-x86_64/vsyscall.h | 1 +
| 3 files changed, 4 insertions(+), 2 deletions(-)
|
|diff --git a/arch/x86_64/vdso/vclock_gettime.c b/arch/x86_64/vdso/vclock_gettime.c
|index 5e15d01..3e586bf 100644
|--- a/arch/x86_64/vdso/vclock_gettime.c
|+++ b/arch/x86_64/vdso/vclock_gettime.c
--------------------------
File to patch:
I don't know what file should be changed so I tried to get that from the patch file itself. But of course there is no directory arch/x86_64/vdso/
This is the full patch file. Any help on how to install it?
A patch file like this contains the differences between two versions of text files.
This one contains changes to these source files:
arch/x86_64/vdso/vclock_gettime.c | 4 ++--
arch/x86_64/vdso/vextern.h | 1 +
include/asm-x86_64/vsyscall.h | 1 +
You can't install it. You can use it to patch the source code (if you have it), compile it and install the results. But I don't think that is what you want.
If you want to install bugfixes use your package manager (I guess it's 'yum' for RedHat).
I'm not good with patch files, but it seems to be a patch file in the 'git format'.
The easiest way to apply such files would be to
1) git clone <path_to_kernel_sources>
2) git checkout 13fac179aa50556ba3c60790a9beb6ca9d0b1b8b
3) git apply <patch_file>
That should take care of automatically applying it for you.
I'm not entirely sure if the commit ID 13fac179aa50556ba3c60790a9beb6ca9d0b1b8b is the correct one. I just picked that up from the e-mail part of your post.
You probably need some more arguments to patch(1). In particular, try
patch -p1 --verbose -i file