I am trying to setup up some test cases using pytest for a project i'm working on and have setup my directory like so.
C:.
│ OpenGLTestCase.py
│ Sprite.py
│ SpriteManager.py
│ SpriteRenderer.py
│ Texture.py
│ __init__.py
│
├───.pytest_cache
│ │ .gitignore
│ │ CACHEDIR.TAG
│ │ README.md
│ │
│ └───v
│ └───cache
│ lastfailed
│ nodeids
│ stepwise
│
├───tests
│ │ colorGrid.png
│ │ OpenGLTestCaseExample.py
│ │ OpenGLTestCaseExample2.py
│ │ test.png
│ │ test.svg
│ │ test2.png
│ │ test3.png
│ │ test_over_colorGrid_at_128left_256_top.png
│ │ test_over_uvGrid_at_128left_256_top.png
│ │ test_render_image_expected.png
│ │ test_render_triangle_expected.png
│ │ test_sprite_manager.py
│ │ test_Texture.py
│ │ uvGrid.png
│ │
│ └───__pycache__
│ test_sprite_manager.cpython-37-pytest-5.0.0.pyc
│ test_sprite_manager.cpython-37-PYTEST.pyc
│ test_Texture.cpython-37-pytest-5.0.0.pyc
│ test_Texture.cpython-37-PYTEST.pyc
│
└───__pycache__
OpenGLTestCase.cpython-37.pyc
Sprite.cpython-37.pyc
SpriteManager.cpython-37.pyc
SpriteRenderer.cpython-37.pyc
Texture.cpython-37.pyc
__init__.cpython-37.pyc
The parent folder that holds all of this is called "pygameOpenGLUtil". I have my main 4 files in the highest directory along with my __init__.py. When I try and run pytest at this level it says throws a "ModuleNotFoundError: No module named 'pygameOpenGLUtil'". This thrown in my test_sprite_manager.py file. I've gotten this to work in other projects before but I can't seem to figure out what is wrong with this one I am sure i'm just forgetting something small.
Here is my __init__.py:
from .OpenGLTestCase import *
from .Sprite import *
from .SpriteManager import *
from .SpriteRenderer import *
from .Texture import *
And here is my test_sprite_manager.py:
import pygame
from OpenGL.GL import *
from pygameOpenGLUtil import *
class SpriteManagerTest(OpenGLTestCase):
def test_add_sprite(self):
test_sprite_map = SpriteManager()
test_sprite_one = Sprite(test_sprite_map)
test_sprite_one = Sprite(test_sprite_map)
if __name__ == "__main__":
unittest.main()
I am running python3.7.3 and pytest version 5.0.0
Related
Currently i'm having a file structure like below.
├── src
│ ├── common
│ │ ├──constants.py
│ │ └──configs.py
│ ├── utils
│ │ ├──module1.py
│ │ └──module2.py
│ └── service
│ │ ├──module3.py
│ │ └──module24.py
│ └── main.py
├── test
│ ├── utils
│ │ ├──test_module1.py
│ │ └──test_module2.py
My test_module1.py includes
# test_module1.py
import sys
sys.path.append("./.")
from src.utils.module1 import filter_file
from unittest import TestCase, main, mock
utils/module1.py includes
# module1.py
from common.constants import LOG_FORMAT, TIME_FORMAT
...
Here, when i try to run test_module1.py file from root i get an error saying that,
$- python3 test/utils/test_module1.py
$- ModuleNotFoundError: No module named 'common.constants'
what is the issue here
Tested it, works like this on Windows:
├── src
│ └── utils
│ └──lib.py
├── test
│ └── utils
│ └──bla.py
lib.py:
def test():
print("woo")
bla.py:
import os
import sys
sys.path.append(".." + os.sep + "..")
from src.utils.lib import test
test()
how do you do?
I'm trying to figure out why some requests to my Images API (usually the last ones) are taking over than 1 minute to load. The first ones are basically instantaneous. Search all over the internet, but had no apropriate answer yet. I am using Google Cloud to storage the images and NodeJS at the server, who is providing the images as a bufferized writing head to the browser.
You can check what am I saying accessing the website (18 year old content):
https://divinasacompanhantes.com/
As you can see, some images just don't load properly. I'm worried because this website is expected to have thousands more profiles, all over the world.
I am using PM2 to handle the services at the server side (2GB available memory). Here's the table:
┌─────┬─────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼─────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 7 │ ServiceAfiliado │ default │ 1.0.0 │ fork │ 31312 │ 20m │ 3 │ online │ 0% │ 55.9mb │ root │ disabled │
│ 0 │ ServiceAvaliacao │ default │ 1.0.0 │ fork │ 31249 │ 20m │ 3 │ online │ 0% │ 55.2mb │ root │ disabled │
│ 8 │ ServiceBlog │ default │ 1.0.0 │ fork │ 31330 │ 20m │ 3 │ online │ 0% │ 61.1mb │ root │ disabled │
│ 1 │ ServiceChat │ default │ 1.0.0 │ fork │ 31256 │ 20m │ 3 │ online │ 0% │ 57.3mb │ root │ disabled │
│ 9 │ ServiceConfig │ default │ 1.0.0 │ fork │ 31337 │ 20m │ 3 │ online │ 0% │ 56.2mb │ root │ disabled │
│ 10 │ ServiceImage │ default │ 1.0.0 │ fork │ 31904 │ 0s │ 13 │ online │ 0% │ 19.1mb │ root │ disabled │
│ 2 │ ServiceLead │ default │ 1.0.0 │ fork │ 31269 │ 20m │ 3 │ online │ 0% │ 54.8mb │ root │ disabled │
│ 3 │ ServiceMail │ default │ 1.0.0 │ fork │ 31276 │ 20m │ 3 │ online │ 0% │ 43.3mb │ root │ disabled │
│ 4 │ ServicePagamento │ default │ 1.0.0 │ fork │ 31289 │ 20m │ 3 │ online │ 0% │ 42.5mb │ root │ disabled │
│ 5 │ ServiceParceiro │ default │ 1.0.0 │ fork │ 31296 │ 20m │ 3 │ online │ 0% │ 60.1mb │ root │ disabled │
│ 6 │ ServicePerfil │ default │ 1.0.0 │ fork │ 31309 │ 20m │ 3 │ online │ 0% │ 69.7mb │ root │ disabled │
└─────┴─────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
The route handling this specific request:
router.get('/image/:imageId', async function (req, res) {
try {
let imageId = req.param('imageId')
let returnImage = await cloudController.getImageFromBucket('fotos_perfil', imageId)
res.writeHead(200, {'Content-Type': 'image/jpg'});
returnImage.on('data', (data) => {
res.write(data)
})
returnImage.on('error', (error) => {
res.status(400).send('Erro lendo a imagem')
console.error(error)
})
returnImage.on('end', () => {
res.end()
})
} catch (err) {
res.status(500).send('Internal Server Error')
}
})
And the controller associated:
async function getImageFromBucket(bucket, imageId) {
return new Promise((resolve, reject) => {
try {
let imageInfo = storage.bucket(bucket).file(imageId).createReadStream()
resolve(imageInfo)
} catch (e) {
reject(e)
}
})
}
Can anyone provide me some ideas to solve this? I've read the official Google documentation and the tip is to use fast-crc32c, but only. No clues on how to configure...
I'm currently trying to spawn a process inside my node server to take a screenshot of the only screen attached to my raspberry with this command :
var scrot = childProcess.spawn(path.join(__dirname, "bin", "scrot", "scrot"), [options.output]);
This command work on my local machine but I get a code 2 response when I try to run it on my headless raspberry under Debian. I suspect it is because my node process is spawned at the beginning of the boot routine, before the x server is started.
The pstree command show me this :
systemd─┬─avahi-daemon───avahi-daemon
├─bluetoothd
├─cron
├─2*[dbus-daemon]
├─dbus-launch
├─dhcpcd
├─hciattach
├─login───startx───xinit─┬─Xorg───{InputThread}
│ └─openbox─┬─openbox-autosta───sh───chromium-browse─┬─ch+
│ │ ├─ch+
│ │ ├─{A+
│ │ ├─{B+
│ │ ├─{C+
│ │ ├─{C+
│ │ ├─{C+
│ │ ├─{C+
│ │ ├─{C+
│ │ ├─{D+
│ │ ├─{N+
│ │ ├─2*+
│ │ ├─3*+
│ │ ├─{T+
│ │ ├─7*+
│ │ ├─{c+
│ │ ├─{e+
│ │ ├─{g+
│ │ ├─{i+
│ │ ├─{r+
│ │ └─{s+
│ └─ssh-agent
├─node───9*[{node}]
Is there a way to add a child process to the x server context ?
Thanks for any help in advance,
C.
guys
I need a help regarding using Vue and webpack with my existing project.
I have built my website using nodejs express server among with ejs as templates.
actually, I want to change the front end of my website totally. And I wanna use Vuetify as the primary frontend framework. But I have never implemented web pack in an existing project. can anyone please help me to do it?
My project file structure is following:
├───includs
│ func.js
│ mailer.js
│ middlewares.js
│
├───models
│ BruteForceSchema.js
│ coupon.js
│ invoice.js
│ payment.js
│ product.js
│ services.js
│ statement.js
│ ticket.js
│ user.js
│
├───routs
│ │ auth.js
│ │ footer.js
│ │ index.js
│ │ products.js
│ │ profile.js
│ │
│ ├───admin
│ │ coupon.js
│ │ index.js
│ │ plans.js
│ │ recharge.js
│ │ services.js
│ │ tickets.js
│ │ users.js
│ │
│ └───clientarea
│ hostings.js
│ index.js
│ recharge.js
│ statement.js
│ tickets.js
│
└───views
│ 404.ejs
│ index.ejs
│
├───admin
│ │ activeService.ejs
│ │ editplan.ejs
│ │ editservice.ejs
│ │ index.ejs
│ │ newplan.ejs
│ │ plans.ejs
│ │ recharge.ejs
│ │ services.ejs
│ │ users.ejs
│ │ viewplan.ejs
│ │ viewservice.ejs
│ │
│ ├───coupon
│ │ addnew.ejs
│ │ edit.ejs
│ │ index.ejs
│ │ view.ejs
│ │
│ ├───tickets
│ │ index.ejs
│ │ view.ejs
│ │
│ └───users
│ editUser.ejs
│ userlist.ejs
│ viewUser.ejs
│
├───auth
│ login.ejs
│ newpassword.ejs
│ resetpwd.ejs
│ signup.ejs
│
├───clientarea
│ │ head.ejs
│ │ hostings.ejs
│ │ index.ejs
│ │ recharge.ejs
│ │ recharge_old.ejs
│ │ statement.ejs
│ │ viewhosting.ejs
│ │
│ └───payments
│ proceed.ejs
│
├───email
│ │ resetdone.ejs
│ │ welcome.ejs
│ │
│ └───searvice
│ renewDone.ejs
│ renewFailed.ejs
│
├───footer
│ aboutus.ejs
│ contactus.ejs
│ development.ejs
│ privacy.ejs
│ tos.ejs
│
├───inc
│ admincpsider.ejs
│ footer.ejs
│ func.ejs
│ header.ejs
│ usercpsider.ejs
│
├───products
│ buy.ejs
│ filehosting.ejs
│ index.ejs
│ info.ejs
│ shared-hosting.ejs
│ wordpress.ejs
│
├───profile
│ edit.ejs
│ index.ejs
│
└───tickets
index.ejs
newTicket.ejs
view.ejs
├───app
│ ├───modules
│ │ ├───asd
│ │ │ ├───angular
│ │ │ │ ├───src
│ │ │ │ └───test
│ │ │ ├───app
│ │ │ │ └───src
│ │ │ ├───base
│ │ │ │ └───src
│ │ │ │ └───client
│ │ │ ├───common
│ │ │ │ ├───json
│ │ │ │ │ ├───src
│ │ │ │ │ └───test
│ │ │ │ ├───src
│ │ │ │ └───test
│ │ │ └───test
│ │ ├───core
│ │ │ ├───base
│ │ │ │ ├───docs
│ │ │ │ └───src
│ │ │ ├───ui
│ │ │ │ ├───directives
│ │ │ │ │ └───src
│ │ │ │ │ └───bmbDropdownMenu
│ │ │ │ │ └───css
│ │ │ │ ├───directives.CategorizedList
│ │ │ │ │ └───docs
│ │ │ │ ├───directives.noResults
│ │ │ │ │ └───lang
│ │ │ │ └───directives.popover
│ │ │ │ └───docs
Is it possible to remove all files and directories inside "app/modules" exception folder "core" via rimraf or another module?
I'm trying like this (doesn't work):
rimraf('./app/modules/(!(core)|**)/*.*', callback);
I spent a lot of time on this, only to figure out that rimraf doesn't support globbing.
I went with del instead, which supports the same format as gulp (an array of paths, including negated ones).
var globby = require('globby');
var rimraf = require('rimraf');
globby(['*', '!app/modules/core.js'])
.then(function then(paths) {
paths.map(function map(item) {
rimraf.sync(item);
});
});
For more info, see the globby documentation
Credit: vladimir-starkov