mirror of
https://github.com/uroni/urbackup_backend.git
synced 2025-10-26 11:36:50 +00:00
Allow bundling of python on windows
This commit is contained in:
parent
bceb406544
commit
36fa87d53e
4
.gitignore
vendored
4
.gitignore
vendored
@ -79,4 +79,6 @@ urbackup/clientlist_*.ub
|
||||
version_new.txt
|
||||
urbackup/sqlite3.exe
|
||||
urbackup/doc/*
|
||||
!urbackup/doc/admin_guide.tex
|
||||
!urbackup/doc/admin_guide.tex
|
||||
pychart/build/*
|
||||
pychart/dist/*
|
||||
1
main.cpp
1
main.cpp
@ -242,6 +242,7 @@ int my_init_fcn_t(int argc, char *argv[])
|
||||
wchar_t buf[MAX_PATH+1];
|
||||
GetModuleFileNameW(NULL, buf, MAX_PATH);
|
||||
Server->setServerWorkingDir(ExtractFilePath(buf));
|
||||
SetCurrentDirectory(ExtractFilePath(buf).c_str());
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
|
||||
@ -1,21 +1,21 @@
|
||||
/*************************************************************************
|
||||
* UrBackup - Client/Server backup system
|
||||
* Copyright (C) 2011 Martin Raiber
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
**************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* UrBackup - Client/Server backup system
|
||||
* Copyright (C) 2011 Martin Raiber
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
**************************************************************************/
|
||||
|
||||
#include "Pychart.h"
|
||||
#include "../Interface/Server.h"
|
||||
#include "../stringtools.h"
|
||||
@ -94,9 +94,18 @@ void Pychart::operator()(void)
|
||||
static int t_num=0;
|
||||
|
||||
if(t_num==0)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::string *prg_name=new std::string;
|
||||
*prg_name=Server->ConvertToUTF8(Server->getServerWorkingDir());
|
||||
Py_SetPythonHome((char*)prg_name->c_str());
|
||||
#endif
|
||||
Py_Initialize();
|
||||
}
|
||||
else
|
||||
{
|
||||
Py_NewInterpreter();
|
||||
}
|
||||
|
||||
++t_num;
|
||||
|
||||
@ -109,7 +118,7 @@ void Pychart::operator()(void)
|
||||
}
|
||||
catch(error_already_set const &)
|
||||
{
|
||||
Server->Log("Error while inizializing Python occured. Did you install numpy and matplotlib?", LL_ERROR);
|
||||
Server->Log("Error while inizializing Python occured. Did you install numpy and matplotlib?", LL_ERROR);
|
||||
PyErr_Print();
|
||||
}
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PYCHART_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\Program Files\Python27\include</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>C:\Program Files\Python27\include;D:\boost</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
||||
23
pychart/setup_pychart.py
Normal file
23
pychart/setup_pychart.py
Normal file
@ -0,0 +1,23 @@
|
||||
from distutils.core import setup
|
||||
import matplotlib as mpl
|
||||
import py2exe
|
||||
import sys
|
||||
|
||||
sys.argv.append('py2exe')
|
||||
|
||||
opts = {
|
||||
'py2exe': {"bundle_files" : 3,
|
||||
"includes" : [ "socket", "sysconfig", "matplotlib.backends",
|
||||
"matplotlib.backends.backend_qt4agg",
|
||||
"pylab", "numpy",
|
||||
"matplotlib.backends.backend_tkagg"],
|
||||
'excludes': ['tcl', 'tcl8.5', 'tk8.5', '_gtkagg', '_tkagg',
|
||||
'_cairo', '_cocoaagg',
|
||||
'_fltkagg', '_gtk', '_gtkcairo', ],
|
||||
'dll_excludes': ['libgdk-win32-2.0-0.dll',
|
||||
'libgobject-2.0-0.dll']
|
||||
}
|
||||
}
|
||||
|
||||
setup(console=[{"script" : "pychart.py"}],data_files=mpl.get_py2exe_datafiles(),
|
||||
options=opts)
|
||||
@ -44,7 +44,9 @@ const unsigned short tcpport=35621;
|
||||
const unsigned short udpport=35622;
|
||||
const unsigned int shadowcopy_timeout=24*60*60*1000;
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
#define ENABLE_VSS
|
||||
#endif
|
||||
|
||||
#define CHECK_COM_RESULT_RELEASE(x) { HRESULT r; if( (r=(x))!=S_OK ){ Server->Log( #x+(std::string)" failed: EC="+GetErrorHResErrStr(r), LL_ERROR); if(backupcom!=NULL){backupcom->AbortBackup();backupcom->Release();} return false; }}
|
||||
#define CHECK_COM_RESULT_RELEASE_S(x) { HRESULT r; if( (r=(x))!=S_OK ){ Server->Log( #x+(std::string)" failed: EC="+GetErrorHResErrStr(r), LL_ERROR); if(backupcom!=NULL){backupcom->AbortBackup();backupcom->Release();} return ""; }}
|
||||
@ -143,9 +145,11 @@ void IndexThread::updateDirs(void)
|
||||
void IndexThread::operator()(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifndef SERVER_ONLY
|
||||
CHECK_COM_RESULT(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
|
||||
CHECK_COM_RESULT(CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, RPC_C_IMP_LEVEL_IDENTIFY, NULL, EOAC_NONE, NULL));
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#ifdef THREAD_MODE_BACKGROUND_BEGIN
|
||||
SetThreadPriority( GetCurrentThread(), THREAD_MODE_BACKGROUND_BEGIN);
|
||||
@ -864,6 +868,7 @@ bool IndexThread::release_shadowcopy(SCDirs &dir)
|
||||
}
|
||||
#ifndef VSS_XP
|
||||
#ifndef VSS_S03
|
||||
#ifndef SERVER_ONLY
|
||||
if(dir.fileserv)
|
||||
{
|
||||
filesrv->shareDir(dir.dir, dir.orig_target);
|
||||
@ -884,6 +889,7 @@ bool IndexThread::release_shadowcopy(SCDirs &dir)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if defined(VSS_XP) || defined(VSS_S03)
|
||||
ok=true;
|
||||
#endif
|
||||
@ -917,6 +923,7 @@ bool IndexThread::release_shadowcopy(SCDirs &dir)
|
||||
|
||||
#ifndef VSS_XP
|
||||
#ifndef VSS_S03
|
||||
#ifndef SERVER_ONLY
|
||||
if(found)
|
||||
{
|
||||
IVssBackupComponents *backupcom=NULL;
|
||||
@ -953,6 +960,7 @@ bool IndexThread::release_shadowcopy(SCDirs &dir)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if defined(VSS_XP) || defined(VSS_S03)
|
||||
if(found)
|
||||
{
|
||||
@ -1051,6 +1059,7 @@ std::string IndexThread::GetErrorHResErrStr(HRESULT res)
|
||||
std::string IndexThread::lookup_shadowcopy(int sid)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifndef SERVER_ONLY
|
||||
std::vector<SShadowCopy> scs=cd->getShadowcopies();
|
||||
|
||||
for(size_t i=0;i<scs.size();++i)
|
||||
@ -1069,6 +1078,7 @@ std::string IndexThread::lookup_shadowcopy(int sid)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -330,7 +330,7 @@
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;URBACKUP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;URBACKUP_EXPORTS;SERVER_ONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader>
|
||||
@ -339,7 +339,7 @@
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;VssApi.Lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
@ -378,7 +378,7 @@
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;URBACKUP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;URBACKUP_EXPORTS;SERVER_ONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader>
|
||||
@ -387,7 +387,7 @@
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;VssApi.Lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user