Skip to content

Commit 9722a3d

Browse files
committed
Implemented dashboard using tkinter
1 parent 88b67de commit 9722a3d

21 files changed

+1133
-0
lines changed

.gitignore

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.DS_Store
2+
.huskyrc.json
3+
out
4+
log.log
5+
**/node_modules
6+
*.pyc
7+
*.vsix
8+
**/.vscode/.ropeproject/**
9+
**/testFiles/**/.cache/**
10+
*.noseids
11+
.nyc_output
12+
.vscode-test
13+
__pycache__
14+
npm-debug.log
15+
**/.mypy_cache/**
16+
!yarn.lock
17+
coverage/
18+
cucumber-report.json
19+
**/.vscode-test/**
20+
**/.vscode test/**
21+
**/.vscode-smoke/**
22+
**/.venv*/
23+
port.txt
24+
precommit.hook
25+
pythonFiles/lib/**
26+
pythonFiles/get_pip.py
27+
debug_coverage*/**
28+
languageServer/**
29+
languageServer.*/**
30+
bin/**
31+
obj/**
32+
.pytest_cache
33+
tmp/**
34+
.python-version
35+
.vs/
36+
test-results*.xml
37+
xunit-test-results.xml
38+
build/ci/performance/performance-results.json
39+
!build/
40+
debug*.log
41+
debugpy*.log
42+
pydevd*.log
43+
nodeLanguageServer/**
44+
nodeLanguageServer.*/**
45+
dist/**
46+
# translation files
47+
*.xlf
48+
package.nls.*.json
49+
l10n/

Scanner/.vscode/tasks.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"tasks": [
3+
{
4+
"type": "cppbuild",
5+
"label": "C/C++: g++.exe build active file",
6+
"command": "C:\\cygwin64\\bin\\g++.exe",
7+
"args": [
8+
"-fdiagnostics-color=always",
9+
"-g",
10+
"${file}",
11+
"-o",
12+
"${fileDirname}\\${fileBasenameNoExtension}.exe"
13+
],
14+
"options": {
15+
"cwd": "C:\\cygwin64\\bin"
16+
},
17+
"problemMatcher": [
18+
"$gcc"
19+
],
20+
"group": "build",
21+
"detail": "Task generated by Debugger."
22+
},
23+
{
24+
"type": "cppbuild",
25+
"label": "C/C++: cl.exe build active file",
26+
"command": "cl.exe",
27+
"args": [
28+
"/Zi",
29+
"/EHsc",
30+
"/nologo",
31+
"/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
32+
"${file}"
33+
],
34+
"options": {
35+
"cwd": "${fileDirname}"
36+
},
37+
"problemMatcher": [
38+
"$msCompile"
39+
],
40+
"group": {
41+
"kind": "build",
42+
"isDefault": true
43+
},
44+
"detail": "Task generated by Debugger."
45+
}
46+
],
47+
"version": "2.0.0"
48+
}

Scanner/__init__.py

Whitespace-only changes.

Scanner/convert.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def toGB(s):
2+
return round(s/(1024*1024*1024),3)
3+
4+
def toKB(s):
5+
return round(s/(1024),3)
6+
def toMB(s):
7+
return round(s/(1024*1024),3)

Scanner/cpp/Tangerine.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
#include<iostream>
3+
#include<fstream>
4+
#include<Windows.h>
5+
#include<string>
6+
#include <openssl/ssl.h>
7+
#include "md5.h"
8+
#include "scan.h"
9+
using namespace std;
10+
11+
12+
13+
string Process::generate_digest(char* location)
14+
{
15+
string md5;
16+
md5 = CALL_MD5_Function(location);
17+
cout << md5 << endl;
18+
return md5;
19+
}
20+
21+
int main()
22+
{
23+
cout << "Tangerine Solutions\n";
24+
wchar_t array[MAX_PATH];
25+
cout << "enter the location" << endl;
26+
wcin >> array;
27+
Scan scanner;
28+
scanner.ListDirectoryContents(array);
29+
scanner.hasher();
30+
scanner.display();
31+
int stay;
32+
cin >> stay;
33+
return 0;
34+
}

Scanner/cpp/scan.cpp

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#include<iostream>
2+
#include<conio.h>
3+
#include<Windows.h>
4+
#include<fstream>
5+
#include"scan.h"
6+
using namespace std;
7+
8+
bool Scan::ListDirectoryContents(const wchar_t *sDir)
9+
{
10+
WIN32_FIND_DATA fdFile;
11+
HANDLE hFind = NULL;
12+
13+
wchar_t sPath[2048];
14+
15+
//Specify a file mask. *.* = We want everything!
16+
wsprintf(sPath, L"%s\\*.*", sDir);
17+
18+
if ((hFind = FindFirstFile(sPath, &fdFile)) == INVALID_HANDLE_VALUE)
19+
{
20+
wprintf(L"Path not found: [%s]\n", sDir);
21+
return false;
22+
}
23+
24+
do
25+
{
26+
//Find first file will always return "."
27+
// and ".." as the first two directories.
28+
if (wcscmp(fdFile.cFileName, L".") != 0
29+
&& wcscmp(fdFile.cFileName, L"..") != 0)
30+
{
31+
//Build up our file path using the passed in
32+
// [sDir] and the file/foldername we just found:
33+
wsprintf(sPath, L"%s\\%s", sDir, fdFile.cFileName);
34+
35+
//Is the entity a File or Folder?
36+
if (fdFile.dwFileAttributes &FILE_ATTRIBUTE_DIRECTORY)
37+
{
38+
wprintf(L"Directory: %s\n", sPath);
39+
ListDirectoryContents(sPath); //Recursion, I love it!
40+
41+
}
42+
else {
43+
process(sPath);
44+
}
45+
}
46+
} while (FindNextFile(hFind, &fdFile)); //Find the next file.
47+
48+
FindClose(hFind); //Always, Always, clean things up!
49+
50+
return true;
51+
}
52+
53+
54+
int Process::process(wchar_t* file)
55+
{
56+
wcout << "\nProcessing: " << file << endl;
57+
double size = file_size_calculator(file);
58+
cout << "\n\n Size of the file :" << size << "\n";
59+
return 0;
60+
}
61+
62+
int Process::file_size_calculator(wchar_t* file)
63+
{
64+
wcout << "\nComputing the size of " << file<<endl;
65+
ifstream in;
66+
in.open(file, ifstream::ate | ifstream::binary);
67+
double size = in.tellg();
68+
bool duplicate_size = file_duplication_detector(size, file);
69+
if (duplicate_size == true)cout << "Files with duplicate sizes have been found" << endl;
70+
return size;
71+
}
72+
73+
74+
// This memeber function is used to detect files with same sizes
75+
// Note files with same sizes even in bytes is not said to be duplicates!
76+
// It needs to be processed further
77+
bool Process::file_duplication_detector(double size, wchar_t* file)
78+
{
79+
map<double, wchar_t*>::iterator itr;
80+
itr = fileduplicates.find(size);
81+
if (itr != fileduplicates.end())
82+
{
83+
// This will create a list of files with same sizes
84+
list_of_duplicates.push_back(itr->second);
85+
list_of_duplicates.push_back(file);
86+
return true;
87+
}
88+
else
89+
{
90+
fileduplicates[size] = file;
91+
}
92+
return false;
93+
}
94+
95+
void Process::hasher()
96+
{
97+
//Half open and closed iterator implementation!
98+
// I know there are other ways to do this
99+
// But half open and closed method is standard for almost all STL stuffs like vector,deque etc.,
100+
list<wchar_t*>::iterator itr1 = list_of_duplicates.begin();
101+
list<wchar_t*>::iterator itr2 = list_of_duplicates.end();
102+
//Common iterator
103+
// I've heard from someone ++something is faster than something++ for STL iterators
104+
//I've forgetten why :) you may have the answer for it if yes drop some comments please!
105+
map<string, wchar_t*>::iterator dupe;
106+
for (list<wchar_t*>::iterator itr = itr1; itr != itr2; ++itr)
107+
{
108+
char hash[MAX_PATH];
109+
wcstombs(hash, *itr, MAX_PATH);
110+
string md5 = generate_digest(hash);
111+
//Create an iterator for map
112+
dupe = duplicates.find(md5);
113+
if (dupe != duplicates.end())
114+
{
115+
entries.push_back(dupe->second);
116+
entries.push_back(*itr);
117+
}
118+
else
119+
{
120+
duplicates[md5] = *itr;
121+
}
122+
}
123+
}
124+
125+
void Process::display()
126+
{
127+
list<wchar_t*>::iterator itr1 = entries.begin();
128+
list<wchar_t*>::iterator itr2 = entries.end();
129+
for (list<wchar_t*>::iterator itr = itr1; itr != itr2; ++itr)
130+
{
131+
cout << "\n";
132+
wcout << "=> Duplicates" << *itr << "\n";
133+
}
134+
}

Scanner/cpp/scan.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#pragma once
2+
3+
#include<iostream>
4+
#include<string>
5+
#include<map>
6+
#include<list>
7+
using namespace std;
8+
9+
// Processing the files
10+
11+
12+
class Process
13+
{
14+
private:
15+
map<double, wchar_t*> fileduplicates;
16+
list<wchar_t*> list_of_duplicates;
17+
map<string, wchar_t*>hashes;
18+
map<string, wchar_t*>duplicates;
19+
list<wchar_t*> entries;
20+
public:
21+
string generate_digest(char* location);
22+
int process(wchar_t* file);
23+
int file_size_calculator(wchar_t* file);
24+
bool file_duplication_detector(double size, wchar_t* location);
25+
void hasher();
26+
void display();
27+
};
28+
29+
class Scan:public Process
30+
{
31+
public:
32+
bool ListDirectoryContents(const wchar_t *sDir);
33+
};

Scanner/diskutil.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import shutil
2+
import os
3+
from convert import toGB
4+
def show_disk_util():
5+
path=input("Enter the directory name to find disk utilization: ")
6+
if os.path.exists(path):
7+
stat = shutil.disk_usage(path)
8+
print("Disk usage statistics:")
9+
print("Total : {} GB".format( toGB(stat.total)))
10+
print("Used : {} GB".format(toGB(stat.used)))
11+
print("Free : {} GB".format(toGB(stat.free)))
12+
else:
13+
print('%s is not a valid path, please verify' %path)
14+
15+
# display all files with their size
16+
17+
18+
def show_file_usage():
19+
path=input("Enter the directory name to find disk utilization: ")
20+
if os.path.exists(path):
21+
for dirName, subdirs, fileList in os.walk(path):
22+
for filename in fileList:
23+
path = os.path.join(dirName, filename)
24+
if not os.path.exists(path):
25+
continue
26+
filesize = os.path.getsize(path)
27+
print('{} : {} GB'.format(path, toGB(filesize)))
28+
else:
29+
print('%s is not a valid path, please verify' %path)

0 commit comments

Comments
 (0)